Shoumen Agdm Shoumen Agdm - 27 days ago 10
AngularJS Question

How to write angular expressions/controls in MVC 4 Razor input field?

I am currently facing a problem to combine

angular
and
Razor
like

@Html.DropDownListFor(model => model.ClientID, ViewBag.Clients as SelectList,"--Select--", new {@class = "input-filter", @style = "height:35px;", @data_val = "false", @ng-change="myFunc()"})


here
@ng-chnage="myFunc()"
does not work in addition a parsing error is generating, However, if I use pure
javascript/jQuery
then it's working fine. Likewise
@onchange="myFunc()"

So, how can I solve this?? I am very much keen to use
angular
and both
Razor

If I use pure
HTML
then both are working fine. Therefore I need solution of
angular
with
Razor

Thank you.

Answer

Razor doesn't understand - So, try _ instead of - An example of it is like @ng_change="myFunc()" or @data_ng_change="myFunc()" I have faced this problem before. Another things is you didn't mentioned the model for angular like ng-model="modelname" Likewise,

Html.DropDownListFor(model => model.ClientID, ViewBag.Clients as SelectList,"--Select--", new {@class = "input-filter", @style = "height:35px;", @data_val = "false",@ng_model="confirmed",  @ng_change="change()"})

Follow this link for more Link

Comments