3

How can i pass the Url.action with parameter from angular object? refer to new { id ="{{item.Title}}", title = "" } section in code below. i cant do it like id ={{item.Title}} this renders it as an string.

 <div ng-app class="container-fluid">
        <div class="row-fluid">
            <div ng-controller="MostViewedToolController" class="span2">
                <ul class="nav nav-list">
                    <li><a href="#"><h4><b>Most Viewed</b></h4></a></li>
                    <li ng-repeat="item in tools">
                        <a href="@Url.Action("Index", "home", new { id ="{{item.Title}}", title = "" })"> {{item.Title}}</a>
                    </li>
                </ul>
            </div>
            @RenderBody()
        </div>
    </div>
2
  • You have to store Url in angular controller. So you can utilize that parameter over here. Commented May 24, 2014 at 10:31
  • stackoverflow.com/a/42695763/706363 - I have created an URL HtmlHelper extension to help bind angular and MVC routes. Commented Mar 9, 2017 at 12:49

2 Answers 2

2

Please follow the below process, i have implemented it and it's working fine.

< a ng-href="@Url.Action("Index","home")?id={{item.ID}}&title={{item.Title}}"> link_name < / a>

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

Comments

0

This fixed it.

<a ng-href="@Url.Action("Index", "home"){{item.ID}}/{{item.Title}}"> {{item.Title}}</a>

1 Comment

it will not work if you bind thin on parameted view. it will add your value to next url value.

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.