I have searched and read a lot but still confused.
The question is, if i have a directive as below
.directive('someDirective',function(){
return{
scope:{},
bindToController:{
prop:"="
},
templateUrl:'myTemplate.html',
controller:'directiveController'
}
})
.controller('directiveController',function(){
//Do controller stuff
})
Why would i need a link function ? I can pretty much bind the whole DOM to the controller for passing data.(Yes i know that controllers should be used when we want to expose a API function as per the angular docs). Pre angular 1.2 when bindToController did not exist it still made sense.
I have read there is pre and post method, this is where we should be doing stuff such as appending elements etc.But again I'm confused as why would i append stuff when i can just put it in "myTemplate.html".
Can you please give some relevant example where we should be using link and not the controller and what is the difference.