Adeel Khan Adeel Khan - 1 year ago 89
AngularJS Question

how to store Specific Column in scope variable Angularjs

I have

variable, in this variable below image data are store but i don't want yellow highlighted column , how to remove these columns from
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';


<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' >
<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 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'>
<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">

//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++) {

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 Source

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'}; 

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download