Angular M, V & C

The plan

  • Directives - see something
  • Controllers & scopes - get data/behaviour into it
  • Module system - enabling testing
  • Routes and HTTP
  • Testing - testing all of the above

e.g ng-repeat

e.g ng-click

module.controller('clicking',function($scope) {
  $scope.counter = {clicks: 0};
  $scope.clicked = function() {
    $scope.counter.clicks += 1;
  }
})
  

e.g ng-show

Filters

  • quick, declarative transformation of output
  • works with data-binding
  • pure: take data in, return new version

A... module

  • not in core, so we need to include
  • gives us lots of services
<script src='vendor/angular/angular-routes.js'></script>

var ourModule = angular.module("ourModule",["ngRoute"]);