Reputation: 408
How to include Angular directives
in Html Helper
in ASP.NET MVC C#.
I dont know how to include it.
What I have done is following :
@Html.EditorFor(model => model.Questions.Question , new{ng_model="quest"})
{{quest}}
But when I look for source code that does not have ng-model directive
?
Upvotes: 0
Views: 3297
Reputation: 227
We can do it very easily.
@Html.EditorFor(model => model.Email, new { htmlAttributes = new { @ng_change = "call()" ,@class="form-control" }})
Upvotes: 0
Reputation: 1
To include Angular directives in Html Helper you should pass a null parameter as a second then pass the angular directive in a object.
@Html.DropDownList("ViewBag-Name", null, new { ng_model = "Model-Name"})
Where ViewBag-Name contains a SelectList object pass to the view from the controller.
Upvotes: 0
Reputation: 640
The second Argument of Html.EditorFor is for the extended ViewData. It is used by the template. The Default template dont use your additional entries. But it supports htmlAttributes
@Html.EditorFor(model => model.Questions.Question , new { htmlAttributes = new { ng_model="quest" }})
or render it with out any template
@Html.TextBoxFor(model => model.Questions.Question, new { ng_model = "quest" })
Upvotes: 2