angularjs directive controller function executes many time

旧巷老猫 提交于 2019-12-13 20:15:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!