Friday, 29 May 2015

Angular const vs value

//define module
var app = angular.module('app', []);
//define constant
app.constant("mynumberValue", 200);
//define value
app.value("numberValue", 100);
app.value("objectValue", { name: "dotnet-tricks.com", totalUsers: 120000 });
// only difference is that values cannot be used in module config function
app.config(function (mynumberValue) { //here value objects can't be injected
console.log("Before:" + mynumberValue);
mynumberValue = "New Angular Constant Service";
console.log("After:" + mynumberValue);
});
view raw constvsvalue hosted with ❤ by GitHub

No comments:

Post a Comment