A constant can be injected anywhere.
A constant can not be intercepted by a decorator, that means that the value of a constant should never be changed.
var app = angular.module('app', []);
app.constant('PI', 3.14159265359);
app.controller('appCtrl', function(PI) {
var radius = 4;
// calculate area of the circle
var area = PI * radius * radius;
});
Value differs from constant in that value can not be injected into configurations, but it can be intercepted by decorators.
var app = angular.module('app', []);
app.value('greeting', 'Hello');
app.config(function ($provide) {
$provide.decorator('greeting', function ($delegate) {
return $delegate + ' World!';
});
});
Really nice blog post.provided a helpful information.I hope that you will post more updates like this keep updating the blogger on Ruby on Rails Online Training Hyderabad
ReplyDelete