<form ng-app
ng-controller="HelloCtrl as helloCtrl"
ng-submit="helloCtrl.greet()">
<label for="name">Name</label>
<input type="text" id="name" ng-model="helloCtrl.name">
<button type="submit">Greet</button>
</form>
function HelloCtrl() {
this.name = 'Tom Mason';
this.greet = function() {
alert('Hello ' + this.name);
};
}
<input type="text" ng-model="helloCtrl.name">
<form ng-submit="helloCtrl.greet()">
function HelloCtrl($scope, WelcomingService) {}
Source: Google I/O 2013 - Design Decision in AngularJS
Network
ngApp directive:<ANY ng-app="MovieDatabase"> // ... </ANY>
angular.module('MovieDatabase', [])
.config(function() {
// is executed during the provider registration and configuration phase.
})
.run(function() {
// is executed after the injector is created
// and is used to kickstart the application.
});
var movieDatabase = angular.module('MovieDatabase');
angular.module('MovieDatabase.services', []); // A service module
angular.module('MovieDatabase.directives', []); // A directive module
angular.module('MovieDatabase.filters', []); // A filter module
angular.module('MovieDatabase.controllers', []); // A controller module
angular.module('MovieDatabase',
['MovieDatabase.controllers', 'MovieDatabase.filters' /* ... */]);
Source: Official AngularJS Guide
Source: Official AngularJS Guide
<input ng-model="person.name" type="text" />
Hello {{ person.name }}
| (pipe) character
{{ person.name | uppercase }}
{{ 123.456789 | number:2 }}
{{ 123 | currency }}
{{ today | date:'medium' }}
{{ ['Ari', 'Lerner', 'Likes', 'To', 'Eat', 'Pizza'] | filter:'e' }}
{{ 'San Francisco' | limitTo:3 }}
var module = angular.module('MovieDatabase', []);
module.filter('myFilter', function() {
return function(input) {
/* transform input to output */
return output;
}
});