Q:

$scope not working inside a function

I have the following code.  I am using ng-show on html and try to manipulate it on the angular function but it did not work.  I am not sure about the correct way to change a $scope value inside a function.   
On Angular,
app.controller("ControlController", function($scope, $http, $location) {

    $scope.badRequest = false;

    $scope.login = function() {

        $http.post('/login', { 

            email: $scope.email,

            password: $scope.password

            }).then function(res) {

                $location.path('/');

            },function(err) {

                 $scope.badRequest = true;

                 console.log($scope.badRequest); // this will print true. 

                 //But this  does not change the $scope.badRequest on DOM.  

            });

      };

});

On Jade, I have
.incorrect-container(ng-show='badRequest')

Any help?  

A:

Not sure if it's just that you copied it over wrong, but ".then" is a function call.  it should be 
$scope.login = function() {
    $http.post('/login', { 
        email: $scope.email,
        password: $scope.password
    })
    .then(function(data) {
        // do stuff in here with successfully returned data
    })
    .catch(function(err) {
        $scope.badRequest = true;
    });
};

The way you have it, .then is not even being called.  Also, when I ran it as it was, I got syntax errors.  are you not getting those?