C # Razor Forms - Inserting Angular Attributes
I have been learning C # and Asp.net for about 11 days with background in PHP and PHP related frames.
My problem is inserting Angular.js attributes like ng-controller
in input elements generated by Razor.
The problem is that...
@Html.TextBoxFor(model => model.Name, new { @class = "Form__TextType Form__TextInput" })
So this generates an html element input[type=text]
with a class attribute. This syntax does not support append ng-model="someModel"
, but I can do it with creating a dictionary that has all the required attributes for that element on the server side and puts it as the last argument inTextBoxFor()
This method is not very good, although it works. If I want to change the agular attribute, I will have to change the Server side Dictionary object, which can be very error prone.
Is there any other way to add angular attributes to Razor generated elements?
source to share
It looks like this answer to another question might help you solve your problem. If you are on MVC 3, I'm sure the described solution should work for you too. If not, let me know - my mind is still a little fuzzy this morning.
source to share