问题
In angularjs , I am making a treeview using directive.
return {
restrict: "E",
//replace: true,
scope: {member: '=', ShowDetailsCtrlFunc : '&'},
template: "<li><span ng-click=ShowDetailsCtrlFunc()>{{member.NodeName}}</span></li>",
controller: 'MainCtrl',
link: linkerfunc
}
Things are fine, but i observed that controller function calls multiple times while loading. Would be a great learning if explain me the concept behind this. Or is it possible to handle this and let the function execute only once ? I have created below plunker for same.
plunkr
Thanks
来源:https://stackoverflow.com/questions/48669479/angularjs-directive-controller-function-executes-many-time