AngularJS Essentials
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Scope<br />
ng-model="username"<br />
placeholder="Username"<br />
/><br />
<br />
Login<br />
<br />
Consider the following code snippet in the controllers.js file:<br />
parking.controller("loginCtrl", function ($scope, loginService) {<br />
$scope.login = function () {<br />
loginService.login($scope.username, $scope.password);<br />
}<br />
});<br />
Do not let the scope cross the boundary of its controller<br />
We should also take care about not allowing the $scope object to be used far a way<br />
from the controller's boundary. In the following code snippet from the login.<br />
html file, there is a situation where loginCtrl is sharing the $scope object with<br />
loginService:<br />
<br />
<br />
<br />
Login<br />
<br />
Consider the following code snippet in the controllers.js file:<br />
parking.controller("loginCtrl", function ($scope, loginService) {<br />
$scope.login = function () {<br />
loginService.login($scope);<br />
}<br />
});<br />
[ 108 ]<br />
www.it-ebooks.info