【发布时间】:2015-12-18 19:19:59
【问题描述】:
在指令文档中,您可以使用以下内容隔离范围:
.directive('myDialog', function() {
return {
restrict: 'E',
transclude: true,
scope: {
'close': '&onClose'
},
templateUrl: 'my-dialog-close.html'
};
});
我正在尝试编写一个仅限于属性的指令。使用“A”进行限制时,如何获得相同的隔离功能?
.directive('doSomething', function() {
return {
restrict: 'A',
scope: {
'close': '&???'
},
link: function(scope, element, attrs) {
element.on('click', function() {
scope.close();
});
}
};
});
我会像这样使用指令:
<button do-something="doSomething()" type="button">Do Something</button>
【问题讨论】:
标签: javascript angularjs angularjs-directive angularjs-scope