Created
November 24, 2014 12:48
-
-
Save EmmanuelDemey/e9449f640618ce7e962f to your computer and use it in GitHub Desktop.
Slide 45 - To conclude about controllers...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="mainApp" data-ng-controller="MainCtrl"> | |
| Hello, {{currentUser.login}} | |
| <tabset> | |
| <tab heading="Mails" data-ng-controller="MailCtrl"> | |
| <div>You have {{nbMails}} mail(s) in your box.</div> | |
| </tab> | |
| <tab heading="Profile" data-ng-controller="EditCtrl"> | |
| <div> | |
| <input type="text" id="inputLogin" data-ng-model="tmpLogin"/> | |
| <button class="btn" data-ng-click="currentUser.login=tmpLogin;">Change login</button> | |
| </div> | |
| </tab> | |
| </tabset> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var MainCtrl = function($scope) { | |
| $scope.currentUser = { login: "BobSponge", | |
| mail: "sponge@water.bloub", mails: null }; | |
| }; | |
| var MailCtrl = function($scope) { | |
| // Gets all user mails. | |
| $scope.currentUser.mails = [ { id: 1, content: "Test" }]; // TODO | |
| $scope.nbMails = $scope.currentUser.mails.length; | |
| }; | |
| var EditCtrl = function($scope) { | |
| $scope.tmpLogin = $scope.currentUser.login; | |
| $scope.editLogin = function() { | |
| // TODO: update login. | |
| }; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment