I use this simple directive to allow me to have data that is populated by the server (
asp.net mvc views)
marshalled into the appropriate model property in Angular:
.directive('mpValueCopy', function($parse) {
return function(scope, element, attrs) {
if (attrs.ngModel) {
if (element[0].type == "radio") {
if (element[0].checked == true) {
$parse(attrs.ngModel).assign(scope, element.val());
}
} else {
$parse(attrs.ngModel).assign(scope, element.val());
}
}
};
})
Example Usage:
<input type="hidden" ng-model="RegistrationDate" value="<%=Model.RegistrationDate %>" mp-value-copy/>
<input type="text" ng-model="UserName" value="<%= Model.UserName %>" mp-value-copy/>
Cheers, Adam.