why-does-angularjs-rock-06
http://angular-tips.com/blog/2013/08/why-does-angular-dot-js-rock/
by outsider
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
What's your name?:
<input type="text" focus ng-model="user.name" />
<button ng-click="greet()">Click here!</button>
<h3>{{ message }}</h3>
JavaScript
var app = angular.module('app', []);
app.controller('MainCtrl', function($scope) {
$scope.greet = function() {
$scope.message = "Hello, " + $scope.user.name;
}
});
app.directive('focus', function() {
return {
link: function(scope, element, attrs) {
element[0].focus();
}
};
});