如何使用Angularjs检查值是否在数组列表中退出 [英] How Do I Check A Value Is Exits Or Not In A Array List Using Angularjs

查看:137
本文介绍了如何使用Angularjs检查值是否在数组列表中退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 $ scope.Validate = function(){
$ scope.Email = {};
$ http.get(' index.php / Welcome / EmailCheck')。success( function(result){

$ scope.Email = result;

console.log(result);

});

};
$ scope.submitForm = function(){

if ($ scope.Email.Email === $ scope.user .Email){
console.log( Mail Id Alresdy Exists);
}
else
{
$ http({
method:' POST'
url:' index.php / Welcome / Signup'
data:$ scope.user,
headers:{' Content-Type'' application / x- www-form-urlencode'}
})。success(function(data){
$ scope.Enquiry = data;
console.log(data);
$ location.path(' / EnquiryResponse');
});
}
;
};





验证函数 $ scope.Email 从数据库中获取所有电子邮件ID它是一个 arraylist

在Submitform函数中,我从ui获得了一个电子邮件ID,我将电子邮件存储在$ scope.user.Email中。

现在我想检查单个电子邮件($ scope.user.Email)是否存在于多个电子邮件ID ($ scope.Email) ...

解决方案

scope.Validate = function(){


scope.Email = {};


< blockquote> http.get(' index.php / Welcome / EmailCheck')。success(function(result) ){


$scope.Validate = function () {
               $scope.Email = {};
               $http.get('index.php/Welcome/EmailCheck').success(function (result) {

                   $scope.Email = result;

                   console.log(result);

               });

           };
           $scope.submitForm = function () {

               if ($scope.Email.Email === $scope.user.Email) {
                   console.log("Mail Id Alresdy Exists");
               }
               else
               {
                   $http({
                       method: 'POST',
                       url: 'index.php/Welcome/Signup',
                       data: $scope.user,
                       headers: {'Content-Type': 'application/x-www-form-urlencode'}
                   }).success(function (data) {
                       $scope.Enquiry = data;
                       console.log(data);
                       $location.path('/EnquiryResponse');
                   });
               }
               ;
           };



in Validate function $scope.Email getting all Email ids from database and it is a arraylist,
in Submitform function i got a single Email Id from ui i have stored the Email in $scope.user.Email.
now i want to check single Email($scope.user.Email) is Existing or not in Many Email Id($scope.Email)...

解决方案

scope.Validate = function () {


scope.Email = {};


http.get('index.php/Welcome/EmailCheck').success(function (result) {


这篇关于如何使用Angularjs检查值是否在数组列表中退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆