我正在试验角度1.2指令.我有一个模板w / ng-repeat.在param中传递的变量似乎没有被指令看到.这是代码:
小提琴:http://jsfiddle.net/supercobra/vmH3v/
控制器:
angular.module('myApp',[]) .controller('Ctrl',['$scope',function($scope) { $scope.labels= [{name:"abc",color:'blue'},{name:"xxx",color:'red'}]; }]) .directive('prettyTag',function() { return { restrict: 'E',scope: {labelsArray: '@'},template: '<h2>Label list:{{labelsArray}}:</h2><div class="label label-warning" ng-repeat="label in labelsArray">{{label.name}}</div>',restrict: 'E',}; });
HTML:
<div ng-app="myApp" ng-controller="Ctrl"> label Array: {{labels}} <hr> <pretty-tag labelsArray='{{labels}}'></pretty-tag> <hr> </div>