<html ng-app="todoApp"> <body ng-controller="TodoCtrl">
var app = angular.module('todoApp', []); app.controller('TodoCtrl', function($scope){ $scope.todos = [ { text: 'Create presentation', done: true }, { text: 'Send email', done: false } ]; });
{{todo.text}} Add Clear Completed
$scope.addTask = function() { $scope.todos.push( { text: $scope.newTask, done: false } ); $scope.newTask = ""; } $scope.clearCompleted = function() { $scope.todos = $scope.todos.filter(function(todo) { return !todo.done; }) }
it('+1 task when adding task', function() { var controller = createController(), todosLen = $scope.todos.length; $scope.newTask = 'Aha!'; $scope.addTask(); expect($scope.todos.length).toEqual(todosLen + 1); expect($scope.todos[todosLen].text).toEqual('Aha!'); });
it('remove completed items', function() { var controller = createController(), todosLen = $scope.todos.length; $scope.newTask = 'Aha!'; $scope.addTask(); $scope.todos[todosLen].done = false; $scope.clearCompleted(); expect($scope.todos.length).toEqual(todosLen + 1); });
Summer Photos!
{{slide.text}}
var app = angular.module('directivesApp', ['ui.bootstrap']); app.controller('MyCtrl', function($scope){ $scope.alertType = 'success'; $scope.slides = [ { active: true, image: 'images/summer1.jpg', text: 'Summer 1' }, { active: false, image: 'images/summer2.jpg', text: 'Summer 2' }, { active: false, image: 'images/summer3.jpg', text: 'Summer 3' }, { active: false, image: 'images/summer4.jpg', text: 'Summer 4' }, ]; });