Feel free to check out my Plunkr demonstration by clicking here.
In my application's app.js file, I've defined two controllers along with a route provider that includes a resolve function for the TestController.
var app = angular.module('app', ['ngRoute']);
app.controller('DefaultController', ['$scope', function($scope){
$scope.welcome = "Hello World";
}]);
app.controller('TestController', ['$scope', 'context', '$routeParams', function($scope, context, $routeParams){
$scope.text = "TestController loaded!"
}]);
app.config(['$routeProvider', '$httpProvider', function($routeProvider, $httpProvider){
$routeProvider.
when('/test1',{
templateUrl: 'test1.html',
controller: 'TestController',
resolve: {
context: function(){return 'test';}
}
})
}])
Within my HTML code, I utilize an ng-include directive to load test.html in the default view alongside the TestController.
<body ng-controller="DefaultController">
<h1>{{welcome}}</h1>
<div ng-include="'test.html'" ng-controller='TestController'></div>
</body>
I'm trying to figure out if it's possible to resolve the contextProvider directly from the ng-include or if there are better alternative approaches to achieve this. Any guidance on this matter would be highly appreciated.