0
假設我定義自定義指令,像這樣:可以混合模板和鏈接功能嗎?
myModule.directive('myDirective', function() {
return {
template: "<p>hello</p>",
link: function (scope, element, attributes) {
element.text('<p>something else</p>')
}
};
});
當然,這是沒有意義的;鏈接功能將完全覆蓋模板。然而我的問題是,如果有一種方法可以將兩者結合起來,以提高生產力。或者,如果我有鏈接功能的時刻,我可能完全擺脫模板?