0

I am getting this error on my page when I bind a model using the ng-model.

This is how I have written the code -

<section class="row">
    <div class="col-xs-6">
        <h2>Login to edit your Team's data.</h2>

        <div class="form-group">
            <label for="ldap">LDAP</label>
            <input type="text" class="form-control" id="ldap" placeholder="Enter LDAP" ng-model="user.ldap">
        </div>
        <div class="form-group">
            <label for="password">Password</label>
            <input type="password" class="form-control" id="password" placeholder="Password" ng-model="user.password">
        </div>
        <button type="submit" class="btn btn-default" ng-click="submit()">Submit</button>
    </div>
</section>

And this is the code in the controller -

dmeDashControllers.controller('loginCtrl', ['$scope','auth','$location','$http','Base64', function($scope, auth, $location, $http, Base64) {

    $scope.$parent.path = $location.$$path;

    $scope.user = {};
    $scope.user.ldap = '';

    $scope.submit = function() {
        var encoded = Base64.encode($scope.user.ldap + ':' + $scope.user.password);
        $http.defaults.headers.common.Authorization = 'Basic ' + encoded;

        var sendLogin = new auth;

        sendLogin.$checklogin();
        console.log(sendLogin);
    }

}]);

When I enter something in the LDAP text field I get this error. Not sure why this is happening. Removing the line ng-model="user.ldap" fixes it, so I am assuming it has something to do with the model binding, please suggest.

maurya8888
  • 253
  • 1
  • 4
  • 11
  • in your controller, what happens if you replace `$scope.user.ldap = " "` with `user = { ldap: ""}` ? – Shehryar Abbasi Jun 03 '15 at 16:22
  • Same thing. In fact, I get the error even if I change it to just ng-model="xyz". – maurya8888 Jun 03 '15 at 16:32
  • do you get a similar error when inputting something into the password box? – bamboo_inside Jun 03 '15 at 16:39
  • Yes, happens for the password as well. – maurya8888 Jun 03 '15 at 17:06
  • okay, so are you adding `ng-controller="loginCtrl"` in this section of your HTML or is it in the $routeProvider etc? what are the errors in the console, if any? perhaps a plunker or jsfiddle would be helpful. – Shehryar Abbasi Jun 03 '15 at 17:44
  • i made this barebones jsfiddle for you to see if it helps your app: [https://jsfiddle.net/b3wz59p1/](https://jsfiddle.net/b3wz59p1/) perhaps you can contrast and compare the use of `ng-submit` and object `key,value` pairs? GL! – Shehryar Abbasi Jun 03 '15 at 18:20
  • I am using the routes and passing the controller from there. You can check my setup here, http://stackoverflow.com/questions/30622998/ngclass-not-updating-the-class – maurya8888 Jun 04 '15 at 08:35

1 Answers1

0

I was able to fix this by updating the angular-animate.js file to the latest version. Thanks guys for helping me.

maurya8888
  • 253
  • 1
  • 4
  • 11