Skip to content

Instantly share code, notes, and snippets.

@bendrucker
Created February 12, 2016 04:04
Show Gist options
  • Select an option

  • Save bendrucker/3c59c19f240200e749a9 to your computer and use it in GitHub Desktop.

Select an option

Save bendrucker/3c59c19f240200e749a9 to your computer and use it in GitHub Desktop.
Sane Angular controllers, minus the popular anti-patterns
function DeliveryController (injectables...) {
var controller = {
drivers: drivers,
fetch: fetch
}
return controller
function fetch () {
return $http.get('drivers')
.then(function (data) {
controller.drivers = data
})
}
}
<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