AngularJS - goatandsheep/goatandsheep.github.com GitHub Wiki
This is also known as Angular 1
- Can only be compiled after the library has been loaded, so
- 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}
modify data
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:
- Suggestion: favour factories over services to make the transition to Angular easier
- ES6 prefers services
-
$location
: thinkwindow.location
.absUrl()
-
$http
:-
.get(<url>)
: promise.then(function(response){response.data})
-
// 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>);
});
Services that return objects