我有一个component.ts
文件,如下所示:
@Component({
selector: 'app-room-details-detail',
templateUrl: './room-details-detail.component.html',
styleUrls: ['./room-details-detail.component.css']
})
export class RoomDetailsDetailComponent implements OnInit {
private roomDetails = {};
private test = "Hello";
constructor(private roomDetailsService: RoomDetailsService) { }
ngOnInit() {
this.getRoomDetails();
}
public getRoomDetails() {
this.roomDetailsService.getRoomDetails().subscribe(data => {
this.roomDetails = data;
console.log(data);
});
}
}
数据如下:{"floorArea":15.65333333,"volume":56.546333333,"paintRequired":9.768542}
当我添加时:<li>{{roomDetails.floorArea}}</li>
或<li>{{test}}</li>
到我的component.html文件时,在构建时出现此错误:
命令ng build --aot
以代码1退出。
我正在使用Visual Studio 15.7.6
答案 0 :(得分:0)
@JB Nizet,感谢您提供有关使用ng build --aot
的技巧。这样就解决了:
将public roomDetails = {};
更改为public roomDetails;