Say I have angularjs modules called core, customer, and admin. Both customer and admin include core. I want both modules' sites to use the same header, which has a controller (HeaderController). When a user logs in to the site backed by the customer module, I create a constant with the user information on the core module. Wherever I go within the customer module, that constant has the data I put there. There's a link to go to the site backed the admin module and I want to be able to access that constant with the user info from admin (on the HeaderController). Below you'll find snippets of my code. Right now everything on customer works but when I go to admin I get the following:
Error: [$injector:unpr] Unknown provider: currentUserProvider <- currentUser <- HeaderController
Index.cshtml for customer
@{
ViewBag.Title = "Customer";
Layout = "~/Areas/Institutional/Views/Customer/_SiteLayout.cshtml";
}
<br />
<div>
<ng-view></ng-view>
</div>
@section Scripts {
<script type="text/javascript">
angular.module('core').constant('currentUser', @Html.Raw(Json.Encode(Model.Data)));
</script>
}
Module for admin
(function () {
'use strict';
angular
.module('admin',
['core']);
})();
Module for customer
(function () {
'use strict';
angular
.module('customer',
['core']);
})();
Controller where I need to access currentUser (constant)
(function() {
angular
.module('core')
.controller('HeaderController', ['$scope', '$rootScope','currentUser',
function ($scope, $rootScope, currentUser) {
$scope.currentUser = currentUser;
}
]);
})();