
上QQ阅读APP看书,第一时间看更新
Controllers
Controllers are part of the framework to handle the business logic of the application. They should be used to control the flow of data in an application. The controller is attached to the DOM via the ng-controller directive.
To add some actions to our view, we need to create functions on controllers, the way to do this is by creating functions and adding them to the $scope object.
The controllers cannot be used to carry out DOM manipulations, format data and filter data, it is considered best practice in the AngularJS world.
Usually, the controllers inject the service objects to delegate handling the business logic. We will understand services in the next section.