When using the custom instruction compile, how to bind events in postLink?
compile:function(tElement,tAttrs,transclude){
return {
post:function postLink(scope,iEle,iAttrs,controller){
iEle.on('click',function(){
alert(1);
}
}
}
When running, the following pops up: iEle.on is not a function
, what is the cause of this error?
You wrote it wrong, there is a missing bracket when registering the click event
https://jsfiddle.net/hjzheng/...