I'm trying to pre-fill a form with a data from a controller.
Simple code looks like
<div ng-app="app" ng-controller="MainCtrl">
<input name="widget.title" ng-model="widget.title">
<input name="widget.content" ng-model="widget.content">
<button ng-click="set('foo')">set to foo</button>
</div>
and
angular.module('app', [])
.controller('MainCtrl', function($scope) {
$scope.widget = {title: 'abc'};
$scope.widget = {content: 'test'};
$scope.set = function(new_title) {
this.widget.title = new_title;
}
});
but it always pre-fill only last input field
JSFiddle: http://jsfiddle.net/b40nLuf2/