New to angular.js today I tried to add ng-model data attribute to my textbox on my login form. The login form uses Html.TextboxFor helper. I tried the following but visual studio showed me an error

@Html.TextBoxFor(m => m.UserName, new { ng-model="user.name" })

in C# - is not valid.

So here’s a workaround for the same. Use _ (underscore) and Razor will convert the underscore to dash automatically.

This is what worked for me.

@Html.TextBoxFor(m => m.UserName, new { ng_model="user.name" })

Hope this helps. Had posted a question on stackoverflow too – Using angular attributes with TextBoxFor in ASP.NET MVC