Angular6 Method for Change the Development required by Environments Profile Profile

During front-end development, we often need to run or pack different environments based on demand. Fortunately, Angular provides us with Environments configuration, but Angular6.x configuration mode and other configuration of Angular’s other versions are Different, I will introduce the test TEST and pre-produce the pre-environment. Environments configuration.

1. Configuration of Environments under Angular6.x

First, create environments.TS and Environment.pre.ts files under Environments folders, as shown below

angular6根据environments配置文件更改开发所需要的环境的方法 Then add as follows

angular6根据environments配置文件更改开发所需要的环境的方法

and then locular. JSON file, add the following code under Configurations under Architect object: angular6根据environments配置文件更改开发所需要的环境的方法

then find SERVE, add the following code angular6根据environments配置文件更改开发所需要的环境的方法

You can print from the console by running ng serve –configuration = test or Ng Serve -C Test courseware: angular6根据environments配置文件更改开发所需要的环境的方法

{Production: False, Path: “https: //test.Webapi.sxmaps.com/ “} path:” https://test.Webapi.sxmaps.com/ “Production: false __proto__: object
   Running NG Serve --Configuration = pre or NG Serve-c presence, you only need to introduce a place where you need to use environment variables, such as 

Import {environment} from ‘../environments/environment’;
  Similarly, first in ENVIRONMENTS, Angular Other Versions  II 
Create Environment.Test.ts and Environment.Pre.ts, then follow the steps above, add the same content, then go to the Angular-CLI.json file to find Environments, add what is added inside:

The test environment can be run by running NG S –ENV = TEST, and environment can be introduced in need.

angular6根据environments配置文件更改开发所需要的环境的方法 The above is all the content of this article, I hope to help everyone, I hope everyone will support Tumi Cloud.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment