我遇到了一个问题,无法在我的指令模板中展示控制器传递的JSON对象数据。以下是我的代码。
指令
app.directive('heroes', function(){
return{
scope:{
heroes: '='
},
template: '<li ng-repeat="x in hereos">{{ x.Name }} </li>', // DOESNT WORK
link:function(scope,element,attributes){
});
}
}
});
控制器
app.controller('MainController',function($scope, $http){
$scope.getData = function(){
$http({
url: 'js/directives/herolist.php',
method: "GET"
}).success(function (data) { $scope.heroes = data.records; })
}
ng-repeat="x in hereos">
是一个打字错误吧?(Hereos 而不是 heroes) - Peter