文章詳情頁
angular.js - angular應(yīng)用能否直接在html中獲取元素作為參數(shù)傳入函數(shù)
瀏覽:170日期:2024-03-16 16:29:43
問題描述
angular應(yīng)用,請問如何使能夠直接在 html 中使用jquery獲取元素并作為參數(shù)傳入函數(shù)呢?
<button ng-click='vm.getButton($(this))'></button>
var ctrl = this;ctrl.getButton = (elem) => { console.log(elem);};
函數(shù)里面的 this 直接指向了當(dāng)前scope,無法獲取到元素,請問有解嗎?
問題解答
回答1:目前通過下面的方式實現(xiàn)了需求
<button ng-click='vm.getButton($event)'></button>
var ctrl = this;ctrl.getButton = ($event) => { console.log($($event.currentTarget));};
標(biāo)簽:
HTML
上一條:angular.js - angular2+webpack編譯錯誤下一條:angular.js - angularJS service里面存儲的數(shù)據(jù)能夠直接和HTML頁面交互嗎?
相關(guān)文章:
1. android - Genymotion 微信閃退 not find plugin.location_google.GoogleProxyUI2. angular.js - angular中的a標(biāo)簽不起作用3. springboot中不能獲取post請求參數(shù)的解決方法4. python3.x - python連oanda的模擬交易api獲取json問題第五問5. sql語句如何按or排序取出記錄6. python - 《flask web開發(fā)》中為什么發(fā)不出確認(rèn)郵件?7. 初來乍到,相對路徑問題,新手求教8. npm鏡像站全新上線9. 輸入地址報以下截圖錯誤,怎么辦?10. 關(guān)于Apache無法啟動的程序的方式是怎么解決的
排行榜

熱門標(biāo)簽