0

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

3 Answers 3

1

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;

Sign up to request clarification or add additional context in comments.

1 Comment

your right how to get address array please tell me @Anil
0
function pick()
{
    var ret = new Object();
    for(i = 1; i < arguments.length; i++)
       ret[arguments[i]] = arguments[0][arguments[i]];

    return ret;
}
var updateObj =pick($scope.profile, 'full_name', 'Company_name', 'mobile_number', 'address');

Comments

0

var app = angular.module("myapp", []);
app.controller("myCtrl", ['$scope', function($scope) {
  
  $scope.profile=
 [
  {
    "Name": "pravin",
    "phone": "23232",
    "address": [
      {
        "country": "india",
        "code": "4142411"        
      }
    ],
    "payementinfo": [
      {
        "type": "credit",
        "amount": "2541"    ,
        "bank":"SSI"    
      }
    ]
  }
]
  ;

 
  angular.forEach($scope.profile, function(obj) {
       $scope.Name=  obj.Name;
         $scope.phone=obj.phone;
         $scope.country=obj.address[0].country;
        $scope.type=obj.payementinfo[0].type;
   });
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myapp">  
  <div ng-controller="myCtrl">
   Name: <b>{{Name}}</b><br/>
    phone: <b>{{phone}}</b><br/>
   country Name: <b>{{country}}</b><br/>
    type: <b>{{type}}</b><br/>
  </div>
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.