I have two AngularJs Modules, one is my app the other is a list of constants. I want to inject the constant module into my app module and use the constants inside my controllers. I have been able to achieve this inside a factory but I can't access my constants inside my controller.
app module:
(function() {
'use strict';
angular.module('myapp', [
'constants',
'ngMaterial',
'ngCordova',
'ngStorage',
'relativeDate',
'ui.router',
'myapp.services.myservice'
])
constant module:
angular.module('constants', [])
.constant('appName', 'mynewapp');
In my factory where I can access my constants:
(function() {
'use strict';
angular.module('myapp.services.myservice', [])
.factory('Myservice', function ($http, appName) {
console.log(appName); //works great!
My controller where I CANNOT access constants
(function() {
'use strict';
angular.module('myapp')
.controller('MyController', [
'$cordovaOauth',
'$state',
'$rootScope',
'Myservice',
MyController
]);
function MyController($cordovaOauth, $state, $rootScope, Myservice, appName ) {
console.log(appName); //undefined