I'm trying to display only the updated values in controller but I'm getting complete data. How can I get only updated values?
Input field:
<div class="" ng-repeat="fields in containerDetails.containerFields">
<input type="{{features.input}}" minlength="{{features.rules[0].minlength}}" maxlength="{{features.rules[0].maxlength}}" required name="{{name}}" ng-model="features.name" >
</div>
<button ng-click="save()">Save</button>
Clicking save should only pass updated values to controller.
.controller('DemoCtrl', function($scope, $http) {
$http.get('json/test.json').
success(function(data, status, headers, config) {
$scope.containerDetails=data;
console.log(data);
$scope.mode=data.containerProperties.mode;
$scope.user=data.containerProperties.role;
console.log($scope.user);
}).
error(function(data, status, headers, config) {
console.log("error");
});
$scope.save = function() {
$scope.msg = 'Data sent: '+ JSON.stringify($scope.containerDetails);
console.log($scope.msg);
};
I have JSON like:
"containerFields": [
{
"label": "First Name",
"name": "first_name",
"placeholder": "Enter Your first name",
"primary": "no",
"required": "yes",
"type": "text",
"input":"text",
"enum": "false",
"access":"user",
"minlength":"10",
"maxlength":"150",
"rules": [{
"message":"Enter First Name",
"minlength":"10",
"maxlength":"150",
"elementValidate":"aplha"
}]
},
{
"label": "Email",
"name": "email",
"placeholder": "Enter Your email",
"primary": "no",
"required": "yes",
"type": "text",
"input": "email",
"access":"user",
"rules": [{
"message":"Enter valid email",
"elementValidate":"email"
}]
}
]