码迷,mamicode.com
首页 > 其他好文 > 详细

[Angular] Angular CLI

时间:2017-03-24 00:48:41      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:rate   run   define   tle   css   code   imp   .json   fine   

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.ts

export const color = "China";

// environment.fi.ts

export 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=ch
ng serve --env=fi
ng serve --prod

 

[Angular] Angular CLI

标签:rate   run   define   tle   css   code   imp   .json   fine   

原文地址:http://www.cnblogs.com/Answer1215/p/6607536.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!