Commit f7627310 authored by Pascal Hartig's avatar Pascal Hartig

Merge pull request #868 from stephenplusplus/gh-pages

[angularjs] use module instead of global variable.
parents ccb41288 b645c677
/*global angular */
/*jshint unused:false */
'use strict';
/**
* The main TodoMVC app module
*
* @type {angular.Module}
*/
var todomvc = angular.module('todomvc', ['ngRoute'])
angular.module('todomvc', ['ngRoute'])
.config(function ($routeProvider) {
'use strict';
$routeProvider.when('/', {
controller: 'TodoCtrl',
templateUrl: 'todomvc-index.html'
......
/*global todomvc, angular */
'use strict';
/*global angular */
/**
* The main controller for the app. The controller:
* - retrieves and persists the model via the todoStorage service
* - exposes the model to the template and provides event handlers
*/
todomvc.controller('TodoCtrl', function TodoCtrl($scope, $routeParams, todoStorage, filterFilter) {
angular.module('todomvc')
.controller('TodoCtrl', function TodoCtrl($scope, $routeParams, todoStorage, filterFilter) {
'use strict';
var todos = $scope.todos = todoStorage.get();
$scope.newTodo = '';
......@@ -79,4 +81,4 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $routeParams, todoStora
todo.completed = !completed;
});
};
});
});
/*global todomvc */
'use strict';
/*global angular */
/**
* Directive that executes an expression when the element it is applied to gets
* an `escape` keydown event.
*/
todomvc.directive('todoEscape', function () {
angular.module('todomvc')
.directive('todoEscape', function () {
'use strict';
var ESCAPE_KEY = 27;
return function (scope, elem, attrs) {
elem.bind('keydown', function (event) {
if (event.keyCode === ESCAPE_KEY) {
......@@ -14,4 +17,4 @@ todomvc.directive('todoEscape', function () {
}
});
};
});
});
/*global todomvc */
'use strict';
/*global angular */
/**
* Directive that places focus on the element it is applied to when the
* expression it binds to evaluates to true
*/
todomvc.directive('todoFocus', function todoFocus($timeout) {
angular.module('todomvc')
.directive('todoFocus', function todoFocus($timeout) {
'use strict';
return function (scope, elem, attrs) {
scope.$watch(attrs.todoFocus, function (newVal) {
if (newVal) {
......@@ -15,4 +17,4 @@ todomvc.directive('todoFocus', function todoFocus($timeout) {
}
});
};
});
});
/*global todomvc */
'use strict';
/*global angular */
/**
* Services that persists and retrieves TODOs from localStorage
*/
todomvc.factory('todoStorage', function () {
angular.module('todomvc')
.factory('todoStorage', function () {
'use strict';
var STORAGE_ID = 'todos-angularjs';
return {
......@@ -16,4 +18,4 @@ todomvc.factory('todoStorage', function () {
localStorage.setItem(STORAGE_ID, JSON.stringify(todos));
}
};
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment