I need to pass the route parameter to the server responding with the template, so I'm trying to use templateProviderfor several articles / other documents.
I am not getting javascript errors, but the following templateProvidermethod is not even executed. When a property is templateUrlnot commented out, this route works fine.
$stateProvider
.state('org.contacts.add', {
url: '/add',
views: {
'org@': {
controller: 'ContactsAddController',
templateProvider: function($route, $templateCache, $http) {
var url = '/templates/' + $route.current.params.org + '/contacts/add';
$http.get(url, {cache: $templateCache}).then(function(html){
return html;
});
}]
}
}
})
After some experimentation, it seems to $routecause problems. Taking this and using $stateParamsat least runs this code / controller.
However, as long as I see the ajax shooting and the correct html response, it never loads into the view.
templateProvider: function ($stateParams, $http, $templateCache) {
var url = '/templates/contacts/add';
$http.get(url, {cache: $templateCache}).then(function(html){
return html;
});
}
source
share