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.

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I am modifying my approach as you suggested.
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;
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.