[英]Trigger click event in option directive
我需要在點擊選項時觸發點擊事件。 由於某些原因,我無法使用更改事件。
這是我的代碼
.directive('itemOptions', [
function() {
return {
restrict : 'A',
template : "<option ng-value='item_id'>{{item_name}}</option>",
replace : true,
link : function(scope, element, attrs) {
element.on('click', function() {
//get element value
});
}
}
}
])
點擊事件未觸發...
任何幫助將不勝感激。 請沒有更改事件,只有單擊事件。 謝謝。
嘗試
angular.element(element).bind('click',function(){
here get the element ...
})
為什么要為這樣的基本模板創建指令? 您應該閱讀docs ,並在選擇上使用ng-model
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.