angularjs - Multiple usages of same controller in angular -
problem angular. on website have comments. each comment shares same 'ng-controller="commentctrl"' directive. when have 300 comments on web site, there 300 commentctrl instances. in html of controller using ng-disabled="author_provided()" on button. when changing author input text field, 300 comments invoking author_provided() ( because function depends on on author ng-model). causes performance issues. want author_provided() function invoked in controller changing author. how achieve ?
the author_provided function evaluated each comment on every $digest cycle. if must circumvent behavior, suggest adding author provided boolean property of comment object. template code can read: ng-disabled=comment.author_provided
(no function call) , angular evaluate result without calling controller function.
the function called every comment because templating engine can't know result of ng-disabled each comment without evaluating controller function call.
Comments
Post a Comment