AngularJS - goatandsheep/goatandsheep.github.com GitHub Wiki

This is also known as Angular 1

Modules

  • Can only be compiled after the library has been loaded, so

Controllers

  • All controllers included must be included in the div necessary
<div ng-app="myApp" ng-controller="myCtrl">Fun</div>

OR

<div ng-app="myApp">
    <div ng-controller="myCtrl">
        Fun
    </div>
</div>
  • Child controllers receive a snapshot of the parent scope, unless they use {{$parent.value}} instead of just {value}

Filters

modify data

Types

Built with internationalization in mind and are coherent with locale

  • Uppercase: Converts text to uppercase
  • Lower: Converts text to lowercase
  • Currency: Formats text as a currency
  • Filter:
  • OrderBy:

Services

  • Suggestion: favour factories over services to make the transition to Angular easier
  • ES6 prefers services

Built-in

  • $location: think window.location
    • .absUrl()
  • $http:
    • .get(<url>): promise
      • .then(function(response){response.data})

Custom

// create service
app.service('<name>', function() {
  this.<func1> = function(<inputs>) {
    return stuff
  }
})
// use service
app.controller('<name>', function($scope, <name>) {
    $scope.<newName?> = <name>.<func1>(<inputs>);
});

Factories

Services that return objects

⚠️ **GitHub.com Fallback** ⚠️