【问题标题】:Restangular put() not workingRestangular put()不起作用
【发布时间】:2014-11-27 09:29:40
【问题描述】:

我正在使用带有 Angular js 的 restangular。 get() 和 post() 运行良好。但是 put 不起作用。这是代码 -

$scope.submitFunction = function(isValid) {
                if (isValid) {
                    $scope.post = {};
                    $scope.post.id = $scope.form.id;
                    $scope.post.code = $scope.form.code;
                    $scope.post.description = $scope.form.description;
                    Restangular.one('manufacturing/process', $scope.processId). get(). then( function(response1) {

                        $scope.post.version = response1.data.version;
                        $scope.post.put().then(function(response) {
                            alert('updated');
                        }, function(response) {
                            alert('error);
                        });
                    }, function(response1) {
                            alert('error);
                    });
                }
            };

它给了我错误 = $scope.post.put is not a function

【问题讨论】:

  • 找到任何解决方案了吗?

标签: angularjs angularjs-directive angularjs-scope restangular


【解决方案1】:

在您的代码中,对象 $scope.post 引用以下对象

$scope.post = {};

而不是您的 Rectangular 休息服务。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-28
    • 2014-09-23
    • 1970-01-01
    • 2013-10-03
    • 2018-04-02
    相关资源
    最近更新 更多