O
O
okuznetsov12017-01-30 19:27:09
Angular
okuznetsov1, 2017-01-30 19:27:09

Why then(...).error is not a function?

app.js

var app = angular.module('tcpdumpApp', ['lumx']);

    app.controller('TcpdumpController', ['$scope', 'LxNotificationService', '$http', '$log', function($scope, LxNotificationService, $http, $log) {

        $scope.newGenerationCommand = '';
        $scope.tcpdumplists = [];
        $scope.parametrs = '';
        $scope.newPort = '';
        $scope.newHost = '';

    $scope.addTcpdumpTask = function() {

        $http.post('/anguler-tasks-tcpdump2/addData.php',{genCommand:$scope.newGenerationCommand, description:$scope.newDescription})
          .then(function(response) {

                    $scope.notify('success','Команда "' + response.data[0].command + '" успешно сгенерирована!');

                    $scope.tcpdumplists.push({
                            id: response.data[0].id,
                            command: response.data[0].command,
                            description: response.data[0].description,
                            completed: response.data[0].completed
                    });

                })
                .error(function(err){
                    $log.error(err);
                }); 

        };

    }]);

I get "Error: $http.post(...).then(...).error is not a function
[email protected] www.ttt.com/anguler-tasks-tcpdump2/js/app.js:83 :13 ". What's wrong? Tell?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abberati, 2017-01-30
@okuznetsov1

because ...error is not a function. there is no such method for promises. replace with catch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question