ng-repeat不显示任何内容

时间:2015-03-13 12:36:07

标签: javascript angularjs

<div ng-controller="Ctrl">
<div class="" ng-repeat="data in mydata">
  {{data.b.three}}
</div>

function Ctrl($scope) {

$scope.mydata = [{
    "a":"",
    "b":[{
        "one":"",
        "two":  "",
        "three": "1"
        }]
}]

}

我希望它会返回'1',但它没有,我的控制台中也没有错误信息。

1 个答案:

答案 0 :(得分:3)

Html:

<div ng-app="print" ng-controller="Ctrl ">
<div  ng-repeat="data in mydata">
  {{data.b[0].three}}
</div>

JS:

angular.module('print', []).
controller('Ctrl',function ($scope) {

$scope.mydata = [{
    "a":"",
    "b":[{
        "one":"",
        "two":  "",
        "three": "1"
        }]
}]

});

您可以在此处找到所有内容:https://jsfiddle.net/k0tx4qzv/