这是我的HTML代码:
<h3 ng-repeat="goal in goals" ng-controller="AddGoalsCtrl">
<h4 ng-repeat="(key,value) in goal" ng-controller="AddGoalsCtrl">
{{key}} : {{value}}
</h4>
</h3>
这就是我的服务层返回的内容:
[Goal [goalId=1, goalName=goal1, goalDescription=goaldescript, measurementCriteria=crtr, visible=Y], Goal [goalId=2, goalName=goal1, goalDescription=goal 1 description, measurementCriteria=criteria1, visible=Y], Goal [goalId=3, goalName=goal1, goalDescription=goal 1 description, measurementCriteria=criteria1, visible=Y]]
或json:
[{"goalId":1,"goalName":"goal1","goalDescription":"goaldescript","measurementCriteria":"crtr","visible":"Y"},{"goalId":2,"goalName":"goal1","goalDescription":"goal 1 description","measurementCriteria":"criteria1","visible":"Y"},{"goalId":3,"goalName":"goal1","goalDescription":"goal 1 description","measurementCriteria":"criteria1","visible":"Y"}]
但我的html没有打印任何类似键:值.......
答案 0 :(得分:1)
你在部分加载控制器多次。不应该像that.html代码那样:
<div ng-controller="AddGoalsCtrl">
<h3 ng-repeat="goal in goals" >
<h4 ng-repeat="(key,value) in goal">
{{key}} : {{value}}
</h4>
</h3>
</div>
答案 1 :(得分:0)
我在http://plnkr.co/twdDzpxikJMTe0WuN7ro创建了一个plunker。
您不应该嵌套控制器尝试类似以下内容:
<body ng-controller="AddGoalsCtrl">
<div ng-repeat="goal in goals">
<h4 ng-repeat="(key,value) in goal">
{{key}} : {{value}}
</h4>
</div>
</body>
另外,不要将h标记嵌套在另一个标记中,而不是在语法上正确的HTML。我使用div代替外部重复,因为在这个例子中你没有用它做任何事情。