Reputation: 811
$scope.showDetails = function (dashboard_item) {
$log.debug("clicked");
$http({
url: '/Details/Details',
method: 'GET',
data: { name: dashboard_item.FName }
})
};
This will call method, but won't pass name to it and will return to angular controller. Instead of opening/staying on new page.
*onclick="location.href='@Url.Action("Details", "Details", new {name = $scope.dashboard_item.Fname })'"
This will properly open/return new page/view, but it can't access angular variable in razor/server side.
There doesn't seem to be any good examples or any information how to do something as simple as this. I know I should be probably be using angular routes, but I've got no clue how and honestly I would rather stick with asp MVC routing, but anything at this point would do..
TLDR I want to return/call/open new MVC view while passing parameters to it
Upvotes: 1
Views: 2182
Reputation: 189
You can use something like this:
<a ng-href="@Url.Action("Details","Details")?name={{dashboard_item.Fname}}">Link</a>
in your razor view where you are using this angular controller.
UPDATE
To use it on all the elements, not only the anchor, you can create this function in your angular controller:
$scope.go = function ( path ) {
$window.location.href = path;
};
and then on your view you can use something like this:
<tr ng-click="go('@Url.Action("CompanyProfileDetails","User")?name=' + profile.Name)">
*another code here*
</tr>
Upvotes: 5
Reputation: 21
As the razor executes in server side pass new object from client side is not possible but you can do pass as url params
<a href="@Url.Action("Details","Details")?name={{dashboard_item.Fname}}">Your link here </a>
Upvotes: 0