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....

D3adman
  • 5
  • 3
  • How would you know which `ExcerciseName` to send? Is the Action link a part of the `for loop`? – Sajal Sep 15 '17 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). – Igor Sep 15 '17 at 12:31
  • @Sajal Yes its in the loop. – D3adman Sep 17 '17 at 04:16

1 Answers1

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).

Rhumborl
  • 16,349
  • 4
  • 39
  • 45
  • Is there any link or tutorial link that you can share with me to guide me in following what you suggested? – D3adman Sep 17 '17 at 04:15