I'm using ionic framework to build an app. In my form i need to re-populate the dynamic ng-model input field. I refer " How to create Dynamic ng-model in Angular " to create the dynamic ng-model field. it works. But when i'm trying to re-populate that field it was not working (I need to perform CRUD opearation).
My HTML part is:
<div class="row header">
<div class="col col-40">Name</div>
<div class="col col-60">Marks</div>
</div>
<div class="row" ng-repeat="(key, user) in userList">
<div class="col col-40" ng-bind="user.name"></div>
<div class="col col-60">
<input type="text" name="actual_marks" ng-model="markscardData.actual_marks[user.user_id]" placeholder="Please enter the marks" />
</div>
</div>
My controller is like this
.controller('MarkscardAddCtrl', function($scope, $stateParams, $state, $http, $ionicPopup, baseUrl)
{
$scope.markscardData = {};
$http.get(baseUrl+"api_method=markscard.getUserList&api_version=1.0&app_key=12345& course_id="+course+"&subject_id="+subject+"& markscard_id="+markscard).then(function(response){
$scope.userList = response.data.responseMsg;
});
})
The JSON value in $scope.userList like this
[{"name":"Harshith","user_id":"249","actual_marks":"76","min_marks":"40","max_marks":"100"},{"name":"Nithin","user_id":"246","actual_marks":"60","min_marks":"40","max_marks":"100"},{"name":"Prathik","user_id":"247","actual_marks":"70","min_marks":"40","max_marks":"100"},{"name":"Ravee","user_id":"250","actual_marks":"80","min_marks":"40","max_marks":"100"},{"name":"Shivarama","user_id":"248","actual_marks":"90","min_marks":"40","max_marks":"100"}]
I need markscardData.actual_marks[user.user_id] repopulate when form is open in edit mode and it allow update also. Please help me on this. Thanks in advance.