Adding a Controller to the Template

Next, you need to add a controller for HTML elements that you want the AngularJS module to control. You also need to define the controller in your module code.

Line 7 in Listing 20.2 assigns a controller named FirstController to a <div> element. This maps the element in the view to a specific controller, which contains a scope:

07     <div ng-controller="FirstController">

Line 2 in Listing 20.3 shows the FirstController code being added to the firstApp module:

02 firstApp.controller('FirstController', function($scope) {

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.107.116