2016-04-29 42 views
0
$scope.addVersion = function() { 
      var appId = $scope.version.appid; 
      var versionForm = { 
       description: $scope.version.desc, 
       versionNotes: [$scope.version.notes] 
      }; 
      console.log(versionForm); 
      $http({ 
       method: 'POST', 
       data: versionForm, 
       url: '//apps/' + appNumber + '/versions' 
      }).then(function successCallback(response) { 


      }, function errorCallback(response) { 


      }); 
     } 

是的,這個工程。但實際上,$scope.version.notes必須是數組。它的HTML:通過AngularJS發送陣列與其他輸入

<textarea ng-model="version.notes" name="" id="" cols="30" rows="10" class="form-control"></textarea> 

我該如何解決它?謝謝。

+0

你能提供一個你的'$ scope.version.notes'可能作爲一個值保存的例子嗎? – iulian

+0

我想如果你真的想''textarea ng-model =「version.notes」...',那麼'version.notes'應該是一個純字符串(可能包含換行符......) – MarcoS

回答

0
 var versionForm = { 
      description: $scope.version.desc, 
      versionNotes: [].concat($scope.version.notes) 
     }; 

現在versionNotes是一個數組。

0

在textarea ng-model應該是String。不是數組