Created by Howard.Zuo / @右领军大都督
DOMContentLoaded
event or when the angular.js
script is
evaluated if at that time document.readyState
is set to 'complete'
. At this point Angular looks
for the ng-app
directive which designates your application root.
If the ng-app
directive is found then Angular will:
$.get('ajax/users.json', function(users) {
var newUsers = _.map(users, function(user){
return {
title: item.title.toUpperCase(),
name: item.name,
birthday: formatDate(item.birthday, 'yyyy-MM-dd'),
salary: user.salary + ' RMB'
};
});
var compiled = _.template(tpl);
$('#content').append(compiled({
users: newUsers
}));
});
Service.getDisplayUsers()
.success(function(displayUsers){
var compiled = _.template(tpl);
$('#content').append(compiled({
users: displayUsers
}));
});
angular.module('demo', [])
.controller('DmController', ['$scope', '$filter',
function($scope, $filter){
$scope.formattedDate = $filter('date')(new Date(), 'yyyy-MM-dd');// 2015-10-12
}]);
angular.module('demo', [])
.service('DmService', ['$filter',
function($filter){
this.getEuroMoney = function(amount){
return $filter('currency')(amount, '€');// €26.2
};
}]);