Adeel Khan Adeel Khan - 17 days ago 5
AngularJS Question

how to store Specific Column in scope variable Angularjs

I have

$scope.Profile
variable, in this variable below image data are store but i don't want yellow highlighted column , how to remove these columns from
$scope.Profile
variable, i want only full_name, Company_name, mobile_number, address for updation.
How do this please help me.

$scope.Profile = Auth.getCurrentUserSync(); // This variable have below image data,
$scope.updateProfile = function () {
$http.put(properties.customerupdate_path + "/"+Id,$scope.Profile).success(function (response) {
console.log('Inner alert');
// window.location.href = '/customerprofile';
});
}


HTML

<form ng-submit="updateProfile()" >
<div class="form-group">
<label class="col-md-2 control-label" for="inputDefault">Full Name</label>
<div class="col-md-4">
<input type="text" class="form-control" id="inputDefault" ng-model='Profile.full_name ' name='full_name' >
</div>
<label class="col-md-2 control-label" for="inputDefault">Mobile Number</label>
<div class="col-md-4">
<input type="text" class="form-control" id="inputDefault" ng-model='Profile.mobile_number ' name='mobile_number'>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="inputDefault">Company Name</label>
<div class="col-md-4">
<input type="text" class="form-control" id="inputDefault" ng-model='Profile.company_name ' name='company_name'>
</div>
<label class="col-md-2 control-label">Position</label>
<div class="col-md-4">
<input type="text" id="inputDefault" ng-model='Profile.designation ' name='designation' class="form-control ng-pristine ng-untouched ng-valid ng-empty" aria-invalid="false">
</div>
</div>


//how to store array values to json array they add only last array

var arrayLength = $scope.Profile.addresses.length;
for (var i = 0; i < arrayLength; i++) {

$scope.tempObject={full_name:$scope.Profile.full_name,
mobile_number:$scope.Profile.mobile_number,
company_name:$scope.Profile.company_name,
designation: $scope.Profile.designation,
addresses: [{site_name: $scope.Profile.addresses[i].site_name,
street_address: $scope.Profile.addresses[i].street_address,
city: $scope.Profile.addresses[i].city,
state: $scope.Profile.addresses[i].state,
country: $scope.Profile.addresses[i].country,
zip_code: $scope.Profile.addresses[i].zip_code,
phone_number: $scope.Profile.addresses[i].phone_number
}

],


enter image description here

Answer

Create new new object and add required properties to that object. copy value for properties from "profile" object to that object. Then assign that object to profile object.

$scope.profile = {id:'1',full_name:'test'}; 
$scope.tempObject={full_name:$scope.profile.full_name};
$scope.profile=$scope.tempObject;