Software Engineer Java, Application New Technology
Things i like:
"JavaScript is to Java as hamster is to ham"
by Jens Ohlig
"JavaScript is the only language people feel like they don't need to learn to use it"
by Douglas Crockford
<!DOCTYPE html>
<html ng-app>
<head>
<script src="js/angular.min.js"></script>
</head>
<body>
<form>
<label>Your name?</label>
<input type="text" ng-model="name" placeholder="Your name?">
</form>
<h3>My name is {{ name }}!</h3>
</body>
</html>
$scope is an object that refers to the application model.
It
connects the View and the Controller
myController.js
function MyController($scope) {
$scope.name = 'Henk Bakker';
}
myView.html
<form ng-controller="MyController">
<input type="text" ng-model="name">
</form>
The controller is a function that augment the $scope object.
It's used to add a value or to add a behavior to the $scope.
function TodoCtrl($scope) {
$scope.todos = [
{ text: 'Learn AngularJS', done: true },
{ text: 'Create an App', done: false }
];
$scope.addTodo = function () {
$scope.todos.push({ text: $scope.todoText, done: false });
$scope.todoText = '';
};
};
"Teach new tricks to the HTML"
All the attributes that begin with "ng" are AngularJS directives.
How to use directives
<!doctype html>
<html ng-app="myApp">
<head>
<script src="../js/angular.min.js"></script>
</head>
<body>
<ul ng-controller="myListController">
<li ng-repeat="item in items">
{{ item.name }}
</li>
</ul>
</body>
</html>
You can also create you own directive.