Angularjs:不显示自定义指令数据

时间:2014-08-04 04:28:11

标签: angularjs angularjs-directive

控制器

  myApp.controller('TodoListController', ['$scope','restService',
   function($scope,restService) {    
      restService.getAll().$promise.then(function(data){
      console.log("fetch data");
      console.log(data); 
     $scope.abc=data;       
     console.log($scope.abc);      
});;

 }]);

指令

myApp.directive('listSearch', [function () {
return {
    restrict: 'E',
    link: function (scope, iElement, iAttrs) {

    },
    templateUrl:'partials/listSearch.html',
    controller:TodoListController,
};
}])

服务

myApp.factory('restService', ['$resource',
  function($resource){
 return $resource('', {},
    {
       'getAll': {method: "GET", url:'JSON/todos.JSON',isArray:true},
    });
}]);

模板

<div ng-repeat="x in abc">
<a href="#/todos/{{x.id}}">{{x.title}}</a>
 <span ng-bind="x.description"></span>
</div>

我想显示abc中的数据,以查看它是否在控制器文件中,但它不会显示在视图中。我想用指令做这个。如何绑定abc来查看?

0 个答案:

没有答案