1
Когда я отправляю деталь в api с angularJs, у меня появилась ошибка, например, TypeError: $scope.posts.push is not a function
, как я ее исправить? Мой пост код:
AdminApp.controller('AddVehicleModalCtrl', ['$scope', '$rootScope', '$modalInstance','$http','toaster', function ($scope, $rootScope, $modalInstance,$http,toaster) {
$scope.create = function(){
$http.post(AppCore.getGlobalApiUrl()+'vehicle_type', {"vehicle_type": $scope.post.vehicle_type})
.success(function(response, status, headers, config){
$modalInstance.dismiss('cancel');
toaster.pop('success', "post", "done");
$scope.posts.push(response.posts);
$scope.$apply();
})
.error(function(response, status, headers, config){
$scope.error_message = response.error_message;
});
};
$scope.cancel = function() {
$scope.post = "";
$modalInstance.dismiss('cancel');
};
}]);