[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
时间: 2024-10-16 23:19:26

[Angular] Angular CLI的相关文章

angular Ionic CLI连接数据获取数据无限滚动

原文地址:https://www.cnblogs.com/sugartang/p/11432430.html

angular Ionic CLI项目开始

原文地址:https://www.cnblogs.com/sugartang/p/11432440.html

angular Ionic CLI环境搭建安装以及栅格响应式布局

原文地址:https://www.cnblogs.com/sugartang/p/11432480.html

[Angular] Angular Elements Intro

Make sure install the latest Angular v6 with Angular CLI. Checkout ght Github for the code. 1. Create a new application: ng new elementApp 2. Install @angular/elements package: npm i @angular/elements --savenpm i @webcomponents/custom-elements --save

Angular Angular 部分2

临时笔记 太新了,现成的组件少, 自己封装一个 Angular UI 组件 Angular2采用自定义指令(Directive)方式加载jquery插件(别人跟着试了,无法实现) http://www.jb51.net/article/105121.htm 下面是几乎没有语法高亮的原文 http://www.cnblogs.com/liuyt/p/5810100.html AngularJS的组件封装 需求: 将一个Echarts封装成一个通用的AngularJS组件. 需求来源:Echarts

Angular - - angular.forEach、angular.extend

angular.forEach 调用迭代器函数取每一项目标的集合,它可以是一个对象或数组.迭代器函数与迭代器(value.key)一起调用,其中值是一个对象属性或数组元素的值,而数组元素是对象属性的关键或数组元素索引.为函数指定一个可选的上下文. 格式:angular.forEach(obj,iterator,[context]); obj:遍历的对象 iterator:迭代器 [content]: 对象为迭代器函数的上下文(this) 使用代码: var arr = [{ name: "A&q

Angular - - angular.equals

angular.equals 对比两个对象/值是否相等.支持值类型.正则表达式.数组和对象. 如果下列至少有一个是正确的,则将两个对象/值视为相等. 两个对象/值能通过===比较. 两个对象/值是同一类型/他们的属性一致并且通过angular.equals详细比较. 两者都是NaN. (在javascript中, NaN == NaN => false. 但是我们认为两个 NaN 是平等的) 两个值都代表相同的正则表达式 (在JavaScript里, /abc/ == /abc/ => fal

[Angular] Angular Global Keyboard Handling With EventManager

If we want to add global event handler, we can use 'EventManager' from '@angular/platform-broswer'. Now we have a modal component, we want to click 'Esc' key to close the modal. <au-modal class="auth-modal" *auModalOpenOnClick="[loginBut

Angular - - Angular数据类型判断

angular.isArray 判断括号内的值是否为数组. 格式:angular.isArray(value); value: 被判断是否为数组的值. --------------------------------------------------------------- angular.isDate 判断括号内的值是否是一个时间. 格式:angular.isDate(value); value:被判断是否为时间的值. -----------------------------------