AngularJS - Add Select model option in Json string -
html
<form ng-submit="exportvideoform()">     <input type="text" class="form-control" ng-model="exportvideo.exportname" required>      <input type="text" class="form-control" ng-model="exportvideo.description" required>      <select class="form-control" name="selectposition" id="selectposition"            ng-options="position.name position in data.watermarkimgposition track position.id"           ng-model="data.selectedposition"           ng-change="changeposition(data.selectedposition)"           required>     <option ng-show="false" value="">please select</option>     </select> </form> ctrl
$scope.exportvideoform = function() {          $scope.data.selectedposition.id = 'lowerleft';         $scope.exportvideo = $scope.exportvideo.push($scope.data.selectedposition.id); //push watermark position in json string         $scope.exportvideojson = angular.tojson($scope.exportvideo); //convert json  }; output
console.log($scope.exportvideojson) = {"exportname":"myname","description":"mydesc"} when try concat/push position.id, throws exception error: $scope.exportvideo.push not function
how add position.id value existing json string ?
push appending items array. looks want add property json object. do
$scope.exportvideo.id = $scope.data.selectedposition.id; 
Comments
Post a Comment