将您的环境文件导入.ts文件.
import { environment } from '../../environments/environment';
在类中创建必需的字段,在构造函数中将环境中的值分配给这些变量,在.html文件中使用通常的绑定.
.TS
import { Component } from '@angular/core';
import { environment } from '../environments/environment';
@Component({
selector: 'app-root',
templateUrl: './ponent.html',
styleUrls: ['./ponent.css']
})
export class AppComponent {
public production = true;
constructor() {
this.production = environment.production;
}
}
html的
{{production}}