angularjs convert variable value as key in json
Convert string value as key in json object
- $scope.attVal={"a":"fsdfsdfsd","b":"asdfas","c":"asdfas","d":"","e":"fas","f":"asd","g":"","h":"","i":"","j":"","k":""};
- $scope.selectedAttribute="a";
- $scope.attrValue="asdda";
- $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.
Comments
Post a Comment