All:
[UPDATE]: Got answer from this post(which takes time to read, so I just quote a simple answer of my understanding to that post here):
"Note that if you need a compile function and a link function (or pre and post link functions), the compile function must return the link function(s) because the 'link' attribute is ignored if the 'compile' attribute is defined."
I am pretty new to AngularJS directive, when I learn how to use $compile, I got one question, for example:
I can define a directive like:
app.directive("customdir", function(){
return {
restrict:"AE",
compile: function(tmplEL, attrs){
return function(scope, EL, attrs){/*this is the link function*/};
},
link: function(scope, EL, attrs){/*this is also the link function*/}
}
})
My confusion here is: the compile function return a link function while we can define another link function in directive as well, are they same function or they are different function that the link: function(scope, EL, attrs)
can override the link function returned from compile
?
And what is the result if I defined both?
Thanks