此代碼正常工作並使用父控制器作用域;在角度指令和調用對象函數上應用範圍
"<button type='button' post-random-feed >Post review</button>"
.directive("postRandomFeed",['config',function(){
return function(scope,element.attrs){
element.bind("click", function(){
scope.name ="henry";
console.log(element);
});
}
}]);
我的問題是,我想定義一個隔離的範圍,並返回一個對象而不是指令中的函數。這是我的代碼
"<button type='button' post-random-feed >Post review</button>"
.directive("postRandomFeed",['config',function(){
return {
restrict :"A",
scope : {
},
irony : function(element, attrs)
{
element.bind("click", function(){
console.log(element);
});
}
};
}]);
我如何調用該函數的諷刺使得元件註冊click事件任何錯誤請指正。謝謝
你可以把在鏈接功能。 – ngLover