首页 > 代码库 > [Angular] Angular CLI
[Angular] Angular CLI
Create an app with routing config:
ng new mynewapp --routing
If you want to generate a new module with routing , you can also do:
ng g m mynewModule --routing
Define env variable:
You can create a custom env file inside env folder.
// environment.ch.tsexport const color = "China";// environment.fi.tsexport const color = "Finland";
And add those files into .angular-cli.json:
"environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts", "ch": "environments/environment.ch.ts", "fi": "environments/environment.fi.ts" }
Import env file into your component:
import { Component } from ‘@angular/core‘;import {env_country} from ‘../environments/environment‘;@Component({ selector: ‘app-root‘, templateUrl: ‘./app.component.html‘, styleUrls: [‘./app.component.css‘]})export class AppComponent { title = ‘app works!‘; country = env_country;}
Run the app with the env config:
ng serve -e=chng serve --env=fing serve --prod
[Angular] Angular CLI
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。