Answer the question
In order to leave comments, you need to log in
How to compare elements in $scope?
Good afternoon. So we have a form with the fields name, email, password. They are stored (or contained, not sure how exactly) by the newUser model. it looks something like this:
<input type="text" class="form-control" id="regUserName" name="regUserName" placeholder="Ваше имя" ng-model="newUser.name" required/>
<input type="email" class="form-control" id="regUserEmail" name="regUserEmail" placeholder="Email" ng-model="newUser.email" required/>
<input type="password" class="form-control" id="regUserPassword" name="regUserPassword" placeholder="Пароль" ng-model="newUser.password" required/>
<button style="float:right;" class="btn btn-primary" name="signUp" ng-disabled="regForm.$invalid || ConfirmPass(newUser)" ng-click="SignUp(newUser)">Поехали!</button>
$scope.SignUp = function(newUser){
$http.get('php_scripts/check_user.php').success(function(data){
$scope.dbInfo = data;
});
Answer the question
In order to leave comments, you need to log in
I solved the problem a little differently: indeed, if you try to read the elements from the received JSON as $scope.dbInfo[i], then it will give an error. That is the condition
if(newUser.email==$scope.dbInfo[i]){
-----
}
if(newUser.email==$scope.dbInfo[i].email){
-----
}
we have one object, we have another object .... we compare using js.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question