0

When I press Sign In in my autorization it should change the signInValid to true,but unfortunetly only alert working:(

And is it correct to use FOR in angularJS to see is login and pass correct? Or there are some better ways to do it?

Here`s my JS code:

  $scope.signInValid = false;
   $scope.signIn = function (userDetails) {
    for (let i = 0; i < $scope.userlist.length; i++) {
        if (userDetails.login == $scope.userlist[i].username && userDetails.password == $scope.userlist[i].password) {
            alert('welcome')
            $scope.signInValid = true;
        }
    }
}

Here`s HTML code:

  <h1>Permissions allowed: <span style="{{setStyle(signInValid)}}">{{signInValid}}</span></h1>
ttmcswg
  • 67
  • 1
  • 8

2 Answers2

0

And if you invert and set the signInValid property to true first ?

if (userDetails.login == $scope.userlist[i].username && userDetails.password == $scope.userlist[i].password) {
      $scope.signInValid = true;
      alert('welcome');
    }
Michael Desigaud
  • 2,115
  • 1
  • 15
  • 15
  • doesnt work also, if i call alert($scope.signInValid) after setting it to true it will return true but in view value wont change – ttmcswg Aug 25 '17 at 09:44
0

Fixed it by setting controller to body block,my div wasnt inside the controlle scope.Thanks all for answers!

ttmcswg
  • 67
  • 1
  • 8