0

I am experimenting with a mix of angular js and microsoft MVC with Razor.

I would like to use my original razor anchors:

@Html.ActionLink("Create New", "Create", new { elephant = Model.elephant ] } )

but instead of reading from the model, I would like to read from Angular Js data using something equivalent to an angular js expression, similar to:

@Html.ActionLink("Create New", "Create", new { elephant = {{ allAnimals.elephant}} ] } )

Of course, the angular brackets above create a syntax error.

I thought about first setting a variable using the Razor @{} syntax, but again the repeated use of angular brackets cause a problem. I have been unable to find a workaround using ng-bind. I am now thinking that razor and angular js don't mix well together and I will just have to change back to using standard HTML syntax with angular js.

Is my thinking correct?

RickL
  • 3,318
  • 10
  • 38
  • 39
trees_are_great
  • 3,881
  • 3
  • 31
  • 62
  • I dont think you should approach angular that way.. The HTML should be dumb by all accounts.. It might be possible to render the razor before the angular binding, but it would seem like 2x the work – Pogrindis Oct 17 '14 at 10:31
  • Check here: http://www.byteblocks.com/Post/Using-AngularJS-directive-in-MVC-ActionLink – blfuentes Oct 17 '14 at 10:40
  • Thanks. The solution provided works with Url.Action links, but throws an error when I try to use it for Html.ActionLink saying that UrlDecode does not support this as an argument. I'm using MVC4. – trees_are_great Oct 17 '14 at 11:06
  • @Pogrindis I am looking for a way to get the speed and simplicity of angular js loading along with the neat server side logic of mircosoft MVC. Ie, some of my pages really benefit from being an SPA and others benefit from MVC convention and server side validation. If you can see a better way of doing this or can expand on your concerns, then I would be grateful. – trees_are_great Oct 17 '14 at 11:26
  • 1
    Try this then: http://stackoverflow.com/questions/25182830/html-actionlink-and-angularjs-value : Edit – blfuentes Oct 17 '14 at 12:14

0 Answers0