• [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.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
  • 相关阅读:
    迁移学习
    GAN
    PCA
    LSTM
    hdu 1754 I Hate It 线段树
    hdu 4292 Food 最大流
    hdu 2222 Keywords Search AC自动机
    hdu 3572 Task Schedule hdu 2883 kebab 最大流
    poj 1966 Cable TV Network 点连通度
    hdu 2236 匹配
  • 原文地址:https://www.cnblogs.com/Answer1215/p/6607536.html
Copyright © 2020-2023  润新知