Created
February 12, 2016 04:04
-
-
Save bendrucker/3c59c19f240200e749a9 to your computer and use it in GitHub Desktop.
Sane Angular controllers, minus the popular anti-patterns
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
| function DeliveryController (injectables...) { | |
| var controller = { | |
| drivers: drivers, | |
| fetch: fetch | |
| } | |
| return controller | |
| function fetch () { | |
| return $http.get('drivers') | |
| .then(function (data) { | |
| controller.drivers = data | |
| }) | |
| } | |
| } |
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
| <ul> | |
| <!-- Using controllerAs: deliveries --> | |
| <li ng-repeat="driver in deliveries.drivers">{{driver.name}}</li> | |
| </ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment