【发布时间】:2016-10-26 22:47:22
【问题描述】:
我正在尝试使用 ng-repeat 在视图中显示数组中的一些数据,但它不起作用。
这就是我的 html 的样子:
<div>
<p>loop here</p>
<ul>
<li ng-repeat="item in transferTest">{{item.Marks}}</li>
<li>{{item}}</li>
<li>{{item.Marks}}</li>
</ul>
</div>
这就是我的控制器的外观:
$scope.resultsArray.push({"Module_Code": $scope.moduleCode, "Marks" :$scope.marks,"Recommendation" :$scope.moduleRecommendation})
$rootScope.transferTest = $scope.resultsArray;
基本上这就是我的数据的组织方式:
[
{"Module_Code": "IT", "Marks": "70", "Recommendation": "test"}
{"Module_Code": "ACC", "Marks": "30","Recommendation": "testintuber"}
It seems that I am unable to access the $rootScope.transferTest from the view.
【问题讨论】:
-
您确定没有在 rootScope 下的其他范围中定义 transferTest 吗?它是否需要在 rootScope 中?如果需要共享,最好使用服务。
标签: angularjs arrays ng-repeat