I'm looking way to init model with empty value without ng-init or ugly code in controller (my form model is very huge and contains variable amount of fields).
Please to run sample http://jsfiddle.net/c9Q6Y/
"Serialize" link shows "{}" - empty model if input not touched, and {"name":""} if enter something to imput and clear it.
How to adjust AngularJS to init model fields as empty lines by default?
<div ng-app="">
<form name="myForm" ng-controller="Ctrl">
text: <input name="input" ng-model="user.name">
<div>
<a ng-click="Serialize()">Serialize</a>
</div>
{{serializedUser}}
</form>
</div>
function Ctrl($scope) {
$scope.serializedUser = "";
$scope.user = {};
$scope.Serialize = function() {
$scope.serializedUser = JSON.stringify($scope.user);
}
}