import { environment } from '../../environments/environment';
import { Headers } from '@angular/http';
@Injectable()
export class ProjectsService {
private _wpBase = environment.wpBase;
ng build --prod给我一个错误:
ERROR in src/app/projects/projects.service.ts(11,33): error TS2339: Property 'wpBase' does not exist on type '{ production: boolean; }'.
我该如何解决这个问题?该应用运行正常,我尝试使用本指南实施Angular Universal:https://github.com/angular/angular-cli/wiki/stories-universal-rendering
答案 0 :(得分:2)
您可能忘记在 environment.prod.ts 中设置wpBase
属性...
检查您的 environment.ts 和 environment.prod.ts ,看看您是否正确设置了wpBase
。
答案 1 :(得分:1)
快速修复是将环境键入任何:
@Injectable()
export class ProjectsService {
private _wpBase = (environment as any).wpBase;
}
正确的解决方法是为您的环境对象添加类型定义。
interface AppEnv {
production: boolean;
wpBase: // whatever is the correct type
}
export const environment: AppEnv = {
production: false,
wpBase: // whatever is the value
};