I have following scenario,
I have registers my files in $routeProvider as following way by using require.js
$routeProvider
.when("/:Id", {
templateUrl: "Scripts/app/Views/MyHtml.html",
controller: "myController",
resolve: {
load: ['$q', '$rootScope', function ($q, $rootScope) {
var deferred = $q.defer();
require([
'scripts/app/controllers/myController',
], function () {
$rootScope.$apply(function () {
deferred.resolve();
});
});
return deferred.promise;
}]
},
caseInsensitiveMatch: true,
})...
....
..
Now I want to add my global controller in application module
I have this controller in different file.
(function () {
app.controller("commonController", function ($rootScope, $scope){
$scope.commonText = "You got successed."
});
}())
Now I do not want to add commoncontroller file index.html, rather I want to resolve when my app.config execute.
I have done following code in $routeprovider function
var commonController = ['$q', '$rootScope', function ($q, $rootScope) {
var deferred = $q.defer();
require([
'scripts/app/commonController',
], function () {
$rootScope.$apply(function () {
deferred.resolve();
});
});
return deferred.promise;
}]
But how do I resolve this commonController here.
Is there any way to resolve global controllers, directives, services for all common routes.
Thanks