I am trying to initialize a constant with global variable in my angularJS like this:
var app = angular.module('myApp')
.constant('test1', myTest.test1)
.constant('test2', myTest.test2);
The problem is sometimes global variable myTest is not available due to which it throws an error that myTest is not defined. I have tried this also:
.constant('test1', angular.isDefined(myTest)?myTest.test1:'')
.constant('test2', angular.isDefined(myTest)?myTest.test2:'')
But it still throws the same error. Is there any workout to this?