小编Efi*_*sky的帖子

--ng build --env = prod无效

我使用的是angular4(4.4.6)和CLI 1.4.3.我尝试制作环境变量,如本文所述:https: //alligator.io/angular/environment-variables/

我最终得到了3个文件: environment.ts

export const environment = {
  production: false,
  restUrl: 'http://localhost:3000/',
  socketUrl: 'http://localhost:2000'
};
Run Code Online (Sandbox Code Playgroud)

environment.prod.ts

export const environment = {
  production: true,
  restUrl: 'http://139.130.4.5:3000/',
  socketUrl: 'http://139.130.4.5:2000'
};
Run Code Online (Sandbox Code Playgroud)

environment.staging.ts

export const environment = {
  production: true,
  restUrl: 'http://139.130.4.5:3000/',
  socketUrl: 'http://139.130.4.5:2000'
};
Run Code Online (Sandbox Code Playgroud)

我用它们如下:

import { environment } from '../../environments/environment';
 constructor() {
    this.serverUrl = environment.restUrl;
    console.log('the env is:' this.serverUrl');
  }
Run Code Online (Sandbox Code Playgroud)

.angular-cli.json我有以下内容:

"environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts",
        "staging": "environments/environment.staging.ts"
      }
Run Code Online (Sandbox Code Playgroud)

从某种原因,当我运行ng build …

angular

29
推荐指数
4
解决办法
4万
查看次数

如何在Angular中更改整页背景颜色

我试图在Angular中更改整个页面的背景颜色(在没有框架的情况下使用body或html标签).我找不到最佳实践,如果可能的话,我希望它能在框架内,因为我将在未来几年内构建一个应用程序.

css background-color angular

19
推荐指数
4
解决办法
4万
查看次数

角度货币管道没有小数值

我试图在角度使用货币管道显示整数价格,我不需要它为我的号码添加.00,事实是,它不是根据我的指示格式化它.这是我的HTML:

              <h5 class="price"><span>{{billingInfo.amount | currency:billingInfo.currencyCode:'1.0-0'}}</span> {{billingInfo.period}}</h5>
Run Code Online (Sandbox Code Playgroud)

这是我的ts:

ngOnInit() {
      this.billingInfo = {amount: 100, currencyCode: 'USD', period: 'Hour'};
}
Run Code Online (Sandbox Code Playgroud)

这是输出:

$100.00 Hour
Run Code Online (Sandbox Code Playgroud)

我试图做的事情:

1.使用十进制数管道(没有好处,货币管道将其变成一个字符串)

2.add number formater(:1.0-0)到我的currencyPipe但似乎被忽略了

我错过了什么?

angular angular5

10
推荐指数
3
解决办法
1万
查看次数

标签 统计

angular ×3

angular5 ×1

background-color ×1

css ×1