Handouts:
function TodoCtrl($scope, $log) {
// use console log
$log.log('Test');
$scope.addTodo = function() {
$scope.todos.push({text:$scope.todoText, done:false});
$scope.todoText = '';
};
$scope.remaining = function() {
var count = 0;
angular.forEach($scope.todos, function(todo) {
count += todo.done ? 0 : 1;
});
return count;
};
$scope.archive = function() {
var oldTodos = $scope.todos;
$scope.todos = [];
angular.forEach(oldTodos, function(todo) {
if (!todo.done) $scope.todos.push(todo);
});
};
}
$scope; // view model
$log; // console: ie friendly
$window; // testable window counter part
$http; // http requests
// and all our services
<div ng-controller="ProductCtrl">
<ul>
<li ng-repeat="friend in friends">
[] who is yrs old.
</li>
</ul>
<input type="checkbox" ng-model="confirmed" ng-change="change()"
<blink>Click me</blink>
<p>Text</p>
p { color: red}
<p></p>
//Code:
function PasswordCtrl($scope) {
$scope.password = '';
$scope.grade = function() {
var size = $scope.password.length;
if (size > 8) {
$scope.strength = 'strong';
}
else if (size > 3) {
$scope.strength = 'medium';
}
else {
$scope.strength = 'weak';
}
};
}
// test:
var scope = {};
var pc = new PasswordCtrl(scope);
pc.password('abc');
pc.grade();
expect(scope.strength).toEqual('weak');
<tabs>
<pane title="Localization">
<li ng-repeat="todo in todos">
<input type="text" ng-model="todoText" />
<blink>CLICK ME!</blink>
<form ng-submit="addTodo()">
<button ng-click="fireAlert()">
Will be native apis. Now we can get some of benefits with angular. All is safly separeted into scopes.