Reputation: 322
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 coding. So I want to load this success from out side js file. In Js controller I want to give key of the success,instead of "Success"
, I reffered many articals But there is no useful for this scenario.Please give some info to proceed like this,as I am fresher to angularJS
Thanks in advance.
Upvotes: 0
Views: 50
Reputation: 2878
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
Upvotes: 1