2017-04-14

angularjs convert variable value as key in json

Convert string value as key in json object


  1. $scope.attVal={"a":"fsdfsdfsd","b":"asdfas","c":"asdfas","d":"","e":"fas","f":"asd","g":"","h":"","i":"","j":"","k":""};

  2. $scope.selectedAttribute="a";
  3. $scope.attrValue="asdda";
  4. $scope.attVal[$scope.selectedAttribute]=$scope.attrValue;

In this example you can see, we are converting a string variable into a json key. and Updating old json by key.

1 comment:


  1. Good day. I was impressed with your article. Keep it up . You can also visit my site if you have time. Thank you and Bless you always.
    Dedicated Angularjs Developer in India

    ReplyDelete