Angular 2 测试版:ngFor 和表达式
Angular 2 beta: ngFor and expressions
我在一个组件中使用了以下代码,尽管位置设置了正确的值但没有任何渲染:
<div class="row" *ngFor="#dailyForecast of location.forecast.list">
<h4>{{dailyForecast.dt * 1000 }} </h4>
</div>
我猜 Angular 2 无法处理 location.forecast.list
尽管它是我的 TypeScript 组件中的有效对象数组 class.
请提供更多代码。
你应该处理 'location == null' 和 'dailyForecast == null'
试试这些代码:
<div class="row" *ngFor="#dailyForecast of location?.forecast?.list">
<h4>{{dailyForecast?.dt * 1000 }} </h4>
</div>
我在一个组件中使用了以下代码,尽管位置设置了正确的值但没有任何渲染:
<div class="row" *ngFor="#dailyForecast of location.forecast.list">
<h4>{{dailyForecast.dt * 1000 }} </h4>
</div>
我猜 Angular 2 无法处理 location.forecast.list
尽管它是我的 TypeScript 组件中的有效对象数组 class.
请提供更多代码。
你应该处理 'location == null' 和 'dailyForecast == null'
试试这些代码:
<div class="row" *ngFor="#dailyForecast of location?.forecast?.list">
<h4>{{dailyForecast?.dt * 1000 }} </h4>
</div>