0

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.

Naveen
  • 1,067
  • 2
  • 14
  • 36

2 Answers2

2

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.

Community
  • 1
  • 1
mb21
  • 34,845
  • 8
  • 116
  • 142
1

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;
});
Ben Lesh
  • 107,825
  • 47
  • 247
  • 232