我有角度指令,接受url获取远程数据:
...
指令本身:
app.directive('myTag', ['$http', function($http) { return { restrict: 'E', transclude: true, replace: true, //template: '{{imgres.isUrl}}\'/>', scope:{ src:"@", //source AJAX url to dir pictures }, controller:function($scope){ console.info("enter directive controller"); $scope.gallery = []; $http.get($scope.src).success(function(data){ console.info("got data"); $scope.gallery.length = 0; $scope.gallery = data; }); } }
一般来说它可以工作,我可以在FireBug控制台中看到:
enter directive controller GET http://127.0.0.1/srv1 got data
但是,如果我将指令的第二个实例绑定到另一个url:
...
仅适用于以下日志:
enter directive controller GET http://127.0.0.1/srv1 enter directive controller GET http://127.0.0.1/srv2 got data <-- as usual it relates to first directive
难道你不能帮我解决2指令的问题