How To Use Angular Js Constants Values
I want to remove all hard codings in angular controller, For that I want to load all hot codings from another js file, For Example modalHeader = 'Success'; Here Success is a Hot
Solution 1:
You can use constants for this . Constant values can be accessed all over the application . You just inject the constant into controller or service to use.
Define constants or values
var app = angular
.module('test');
app.constant("ENV", {
"CON1": "val1",
"CON2": "val2",
"CON3: "val3",
});
And use in service
angular.module('test')
.service('testService', function($http, ENV)
or in controller
angular.module('test')
.controller('testController ', function($http, ENV)
values are accessible via ENV.CON1
Post a Comment for "How To Use Angular Js Constants Values"