I want to use a variable data in another js file. How do I do that in anularjs.
In one.js file i have a variable tagText="SAP" and I want to use its value in another js file(two.js). How do I do that in angularjs?
Can anyone help please?
I want to use a variable data in another js file. How do I do that in anularjs.
In one.js file i have a variable tagText="SAP" and I want to use its value in another js file(two.js). How do I do that in angularjs?
Can anyone help please?
As of my point of view you can create a service of that file oneService.js
myApp.service('oneService', oneService);
function oneService(){
var tagText;
return {
getTagText:getTagText,
setTagText:setTagText
};
function getTagText(){
return tagText;
}
function setTagText(tagText){
this.tagText=tagText;
}
}
Inject this service in any controller and you can access tagText variable on that controller via getter & setter
Service in Singleton in angular, at a time you have latest value of variable