Unknown Env Provider In Angularjs
I writing one constant file with Reff, I getting the follwing Exception If I tried like that : angular.min.js:118 Error: [$injector:unpr] http://errors.angularjs.org/1.5.8/$inject
Solution 1:
Just change your constant js file as follows, which will make sure to use the global instance of the module
angular.module('App').constant("ENV", {
"status412": "412",
"Success": "Success",
});
Solution 2:
Try it like in this simple demo fiddle. Ensure your config is loaded after your main application into DOM and you will be fine.
AngularJS application
var myApp = angular.module('myApp',[]);
myApp.controller('MyCtrl', function ($scope, ENV) {
$scope.ENV = ENV;
})
myApp.constant("ENV", {
"status412": "412",
"Success": "Success",
});
An other approach is do create your config in an own module and parse it into your main application like in this demo fiddle. This will also work if your config is outsourced into an own file.
AnuglarJS application
var config = angular.module('config',[]).constant("ENV", {
"status412": "412",
"Success": "Success",
});
var myApp = angular.module('myApp', ['config']);
myApp.controller('MyCtrl', function ($scope, ENV) {
$scope.ENV = ENV;
});
Post a Comment for "Unknown Env Provider In Angularjs"