0

I'm getting a list of data and displayed it using angularjs inside table.

<tr dir-paginate="entit in testing>
<td>{{entit.ExerciseName}}</td>
<td>{{entit.Name}}</td>
<td>{{entit.StartingDate}}</td>
<td>{{entit.EndDate}}</td>
</tr>

Now my question is how do I get ExerciseName value to send it to my controller after I click the link?

@Html.EncodedActionLink("View History", "NationalHistory", "Applicant/Testing", new {ExerciseName = (How do I set the value at here) }, new { @class = "btn btn-success btn-sm btn-block"})

By the way I'm using @Html.EncodedActionLink that I'm getting from this link : https://dotnettrace.net/2013/09/19/encrypt-and-decrypt-url-in-mvc-4/

Please help....

3
  • How would you know which ExcerciseName to send? Is the Action link a part of the for loop? Commented Sep 15, 2017 at 12:04
  • A cleaner approach would be to not use MVC controllers at all. Use Web API for data and HTML templates for angular views. Trying to combine razor templates (ie use of mvc controller) and angular templates usually results in bad SOS (separation of concerns). Commented Sep 15, 2017 at 12:31
  • @Sajal Yes its in the loop. Commented Sep 17, 2017 at 4:16

1 Answer 1

1

The Razor code (@Html.EncodedActionLink(...)) is run on the server before the page is rendered by the browser and available for Angular to interact with. Therefore you cannot just get Angular to plug in the data later.

You will need to make an ajax call from your Angular controller/service, probably using the Angular $http service (assuming your tag is correct and you are using Angular 1.x).

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

1 Comment

Is there any link or tutorial link that you can share with me to guide me in following what you suggested?

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.