I have a form built using ASP.NET MVC 5 using @Html.TextBoxFor
to populate the form with my model (e.g, after a form navigation or server side validation failure).
I have now introduced a client side address lookup using Angular which means some of the form fields are now decorated with ng-model
to enable the Angular lookup to populate the searched address.
e.g.:
@Html.TextBoxFor(m => m.Town, new { @class="form-control", ng_model="address.town" })
Adding the ng-model
now overrides the value set from the MVC model when the page is reloaded.
Viewing the source in the browser shows that the textbox value is set correctly to Town
from the MVC model but Angular then comes along and populates it with address.town
which is empty so the form displays no value.
How can I prevent Angular from doing this?