【发布时间】:2014-07-23 23:51:04
【问题描述】:
这是我在模板中的代码。
<button ng-click="{{backFunction}}" ng-show="{{backShow}}"> Back </button>
<button ng-click="{{nextFunction}}" ng-show="{{nextShow}}"> Next </button>
指令代码
directive('navigationButtons', function() {
return {
restrict: 'AE',
templateUrl : 'angular/app/partials/navigationButtons.html',
scope: {
backFunction: '@',
backShow: '@',
nextFunction: '@',
nextShow: '@'
}
};
})
查看代码(我使用指令的地方)
<navigation-buttons nextFunction="a.active=true" nextShow="true" backFunction="b.active=false" backShow="true"></navigation-buttons>
显示错误为Syntax Error: Token 'nextFunction' is unexpected
【问题讨论】:
-
您正在使用“@”定义隔离范围,而我认为一个指令只能有一个隔离范围
-
@aokaddaoc false,您可以拥有多个独立作用域。
标签: javascript angularjs angularjs-directive angular-ui-bootstrap