Question

I am using AngularJS for my client side framework. Using the routeprovider, I want to sent query params to my templateURL for processing. Basically my templateURL is a server side php script which will generate HTML.

Now routeprovider is not sending query params to my server side code. I am getting blank values for all such params.

If my approach is wrong, please correct me.

Was it helpful?

Solution 2

I would recommend against having your server render your HTML for you... but I suppose if you had to do things this way, you could just leverage ng-include:

When you set up your route:

$routeProvider.when('/route/:id', {
    template: '<div ng-include="/Some/Url?id={{id}}"></div>',
    controller: 'FooCtrl'
});

Then your controller:

app.controller('FooCtrl', function($scope, $routeParams) {
   $scope.id = $routeParams.id;
});

OTHER TIPS

The way Angular is meant to be used is that the client requests the content as JSON from the server (with the $http module) and then the HTML is built on the client-side. See what-is-the-point-of-angularjs-routes? I also highly recommend the official tutorial.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top