我需要将数据从控制器传递到 html 模板。我可以看到来自 console.log 的数据,但我没有通过 DOM 看到它。
这是我的组件:
import ItemService from '../../services/test.service.js'
const TestComponent = {
controllerAs: 'testCtrl',
controller: function ($http) {
ItemService.getItems($http)
.then(data => {
this.items = data.categories;
console.log('inside controller', this.items);
})
},
template: require('./test.html'),
bindings: {
}
};
export default TestComponent;
这是模板:./test.html
<div class="test">
NAMES OF ITEMS:
<ul>
<li ng-repeat="item in testCtrl.items">
<p>{{item.name}}</p>
</li>
</ul>
</div>
为什么我看不到列表?