0
考慮以下指令:更改指示功能動態
app.directive("myDirective", function() {
return {
restrict: "AE",
scope: {
myFunction: '&'
},
templateUrl: "some_template.html",
link: function (scope, element) {
}
}
});
我宣佈它作爲
<my-directive my-function="function1()"></my-directive>
但我的問題是,在控制器我需要根據條件function1
或function2
打電話。有沒有辦法動態改變my-function
屬性中的功能?