Here is my html code of angularjs app
<input type="text" class="input-xlarge" id="user_name" ng-model="myModel.text1"
name="user_name" rel="popover" data-content="Enter your first and last name."
data-original-title="Full Name">
And here is the constructor code
function MyCtrl2($scope) {
var initial = {text1: 'initial value'};
var ini = {text2: 'initialvalue'};
$scope.myModel = angular.copy(initial);
$scope.myModel = angular.copy(ini);
}
MyCtrl2.$inject = ['$scope'];
The default value in only one text box usr_email is getting populated.But not in user_name
Can any one point what may be wrong.
You can't use angular.copy as it will override the $scope.myModel when used for the second time (when copying init). Use angular.extend instead, to copy all properties of ini and initial to your model:
function MyCtrl2($scope) {
var initial = {text1: 'initial value'};
var ini = {text2: 'initialvalue'};
$scope.myModel = {};
angular.extend($scope.myModel, initial, ini);
}