If I have a typical route like this:
angular.module('app', ['ngResource']).
config(function($routeProvider, $locationProvider) {
.when('/item/:itemId', {
template: '<div ng-bind-html-unsafe="html"></div>',
controller: blobs.controller.RouteController,
})
});
How can I achieve requesting a 'dynamic view' from the server? ie. the server's route should lead to a dynamic php page, fill in and preserve some data, and return whatever html it wants, based on the given itemId in the route. I tried setting up some complicated route monitoring and ajax requests for a template container, and then injecting the response html, on load of the RouteController, ie:
Service.request('item/'+$routeParams.itemId, {}, function(r) {
$scope.html = r;
$compile($scope.html)($scope); //generates infinite loop for some reason?
$scope.$apply();
});
But this isn't quite working. The PHP's response html get's loaded into the container template just fine, but the data binding doesn't seem to work (ie. it contains {{*}} everywhere).
Is there a better way to do this? I'm really just trying to turn a route like this:
/item/My-Item into a "templateUrl" that is the same, ie: /item/My-Item or /views/item/My-Item ..etc
Thank you for any help!
Ryan