On Github tilmanpotthof / angular-einfuehrung-kurz
<body ng-app>
12
angular .module('helloWorld') .controller('HelloWorldController', function ($scope) { 'use strict'; $scope.name = 'Bernd'; });
{{ word }}
angular.module('myModule') .controller('MyController', function($log, $http) { 'use strict'; $log.info('ENTER MyController'); $http.get('someData.json').success(function (data) { $log.info('LOADED someData.json', data); }); $log.info('LEAVE MyController'); });
angular.module('myModule').factory('userService', function () { 'use strict'; var privateUsersById = {}; var idCounter = 1; var userService = { addUser: function (user) { if (user.id) { throw new Error('User has already a id. Use updateUser() instead'); } user.id = idCounter++;; privateUsersById[user.id] = user; return user; }, removeUser: function (user) { delete privateUsersById[user.id]; }, getUserById: function (id) { return privateUsersById[id]; }, getUsers: function () { return Object.keys(privateUsersById).map(function (id) { return privateUsersById[id]; }); } }; return userService; });
angular.module('myModule') .controller('MyController', function ($scope, userService) { 'use strict'; $scope.userService = userService; });
{{ user.birthdate | date:'dd.MM.yyy' }}
{{ user.sha256 | uppercase | limitTo:7 }}
{{ user.name }}
{{ user.name }}
angular.module('commons').filter('eliminateVowels', function () { 'use strict'; return function (value, disable) { if (angular.isString(value) && !disable) { return value.replace(/[AEIOUaeiou]/g, ''); } else { return value; } }; });