Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
AngularJS

Controllers in AngularJS

Attach view logic with controllers; prefer controller-as syntax.

Controllers in AngularJS — a practical guide to AngularJS controllers with clear examples you can reuse in real projects.

AngularJS Tutorial Series (11/99). Prefer one article? Read the complete AngularJS tutorial.

Short description

Keep controllers thin — move reusable logic to services.

Controller

angular.module('myApp')
  .controller('ProductCtrl', function (ProductService) {
    var vm = this;
    vm.items = [];
    ProductService.list().then(function (items) {
      vm.items = items;
    });
  });

Leave a reply

Your email address will not be published. Required fields are marked *