ng-click =“show ...不在指令中工作

时间:2013-12-02 12:17:09

标签: angularjs angularjs-directive angularjs-ng-click

对于我的生活,我无法正确使用ng-click =“show''”在指令中工作。

HTML

<sortable ng-controller="SortableCtrl"></sortable>

<div ng-show="show=='label-1'"></div>
<div ng-show="show=='label-2'"></div>
<div ng-show="show=='label-3'"></div>           

reports.controller('SortableCtrl', function($scope) {

$scope.sortableArray = [
    {label: "Label 1", ref: "label-1"},
    {label: "Label 2", ref: "label-2"}, 
    {label: "Label 3", ref: "label-3"}
];

});

reports.directive('sortable', function() {
return {
    restrict: 'E'
  , replace: true
  , template: '<ul id="sortable" class="no-margin"><li ng-repeat="item in sortableArray" class="row col-xs-12"><input type="checkbox"><label class="left" ng-click="show=item.ref"><span class="cb-icon"></span></label><span class="report-item left">{{item.label}}</span><span class="icon-move right"></span><span class="clear"></span></li></ul>'

}
});

正如你所看到的,除了ng-click =“show = item.ref”之外,一切正常。如何正确调用item.ref?

0 个答案:

没有答案