I'm a newbie working with AngularJs routing in Asp.net mvc. I've read quite a lot of articles on internet already and might still have a little confusion when it comes to routing.
My problem is, i have multiple MVC controllers take these two for example Reviews and Broker.
In _Layout.cshtml
@Html.ActionLink("See Review", "Index", "Reviews", new { reviewId = 1299 }, null)
My Index action on Reviews controller takes the reviewId. My URL right now takes the form as:
http://localhost:52881/Reviews/Index?reviewId=1299
I want to get this reviewId in my angular controller therefore i have declared my route as:
var reviewModule = angular.module('reviewModule')
reviewModule.config(function ($routeProvider) {
var basePath = 'App/views/partial/';
$routeProvider.
when('/', {
redirectTo: '/reviews'
}).
when('/reviews', {
templateUrl: basePath + 'review/review.html',
controller: 'reviewscontroller'
});
});
Now when i run the application and click on See Review link, my url becomes
http://localhost:52881/Reviews/Index?reviewId=1299#/reviews/
That's probably because angular routing engine took the url after the mvc querystring has ended and called the redirectTo '/reviews'.
In my reviewscontroller.js when i try to get the reviewId, i get an undefined probably because nothing was transferred after the #/reviews/ to angular route. Here is how i am getting the parameter in reviewscontroller.js controller.
console.log($routeParams.listingNumber);
My question is, how asp.net mvc action parameters can become the part of the angular route so that they can later be accessed for further processing?