我使用角度&在工作中重复,这就是为什么我为什么不能渲染而感到困惑的原因。这可能是我忽视的愚蠢行为,但我已经花了足够的时间在上面,因此要求别人提供一些暗示。
相关位:
JS
.controller('ListCtrl', function($scope, dataAPI){
dataAPI.getIndex().then(function(res) {
console.log('server response', res);
$scope.notes = res;
});
玉
h1 Hello this is the list
div(ng-controller='ListCtrl')
div(ng-repeat='note in notes')
div {{ note.dist_path }}
加载数据的控制台日志(对象数组)
server response [Object, Object, Object, Object]
控制台中没有错误。我检查范围,我看到了我期望的确切内容。数组的对象。
答案 0 :(得分:1)
问题在于我的dataAPI
方法getIndex
正在使用外部库(q)来解析请求,而不是将其留给角色$http
和{ {1}}。所以我需要在设置范围变量后调用$q
以警告更改的角度。或者只使用$scope.$apply()
中内置的角度,或使用$q
返回的承诺。