When does controller come into play in AngularJS? -
i trying understand $scope , how controller , view clued together. when angular first runs through dom elements, when finds ng-controller do? know when finds binding variables, creates either watch or keydown events , events injects , watch other related events. done creating scope given dom element. when item changes in view or model can push value proper places. question when controller instantiated , $scope injected , how $scope calls associated methods when event happens? thanks
you have go through documentation on site clarity. understand when framework encounters ng-controller attribute on view, attach , instantiate controller. code directly within controller function run right there. if want code run on events click event put ng-click='myfunction()'
on element , myfunction
$scope property. if want run code inside controller on other event need use $scope.$on
within controller , $scope.$broadcast
trigger event outside. note controller should have business logic. code directly manipulate dom goes within directive. use scope
property in directive bind variables , functions between controller , directive.
again, said, go through documentation , videos on youtube better understanding on foundations of angularjs.
Comments
Post a Comment