全网整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:400-708-3566

Ionic+AngularJS实现登录和注册带验证功能

登录:

<!DOCTYPE html> 
<html> 
<head> 
  <meta charset="utf-8"> 
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 
  <title></title> 
  <link rel="manifest" href="manifest.json" rel="external nofollow" > 
  <!-- un-comment this code to enable service worker 
  <script> 
   if ('serviceWorker' in navigator) { 
    navigator.serviceWorker.register('service-worker.js') 
     .then(() => console.log('service worker installed')) 
     .catch(err => console.log('Error', err)); 
   } 
  </script>--> 
  <link href="lib/ionic/css/ionic.css" rel="external nofollow" rel="stylesheet"> 
  <link href="css/style.css" rel="external nofollow" rel="external nofollow" rel="stylesheet"> 
  <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above 
  <link href="css/ionic.app.css" rel="external nofollow" rel="external nofollow" rel="stylesheet"> 
  --> 
  <!-- ionic/angularjs js --> 
  <script src="lib/ionic/js/ionic.bundle.js"></script> 
  <!-- cordova script (this will be a 404 during development) --> 
  <script src="cordova.js"></script> 
  <!-- your app's js --> 
  <script src="js/app.js"></script> 
  <script src="js/Login.js"></script> 
</head> 
<body ng-app="myApp" ng-controller="myCtrl"> 
  <ion-pane> 
    <ion-content> 
      <div class="bar bar-header "> 
        <div class="h1 title">用户登录</div> 
      </div> 
      <div class="content has-header"> 
        <form ng-submit="onSubmit(myForm.$valid)" name="myForm" novalidate> 
          <div class="list"> 
            <div class="item-input-inset"> 
              <label class="item-input-wrapper"> 
                <i class="icon ion-person"></i> 
                <input type="text" name="user" id="user" ng-model="user" placeholder="用户名" required> 
                <div ng-show="myForm.user.$invalid && submitted"> 
                  <div style="color:red" ng-show="myForm.user.$error.required">用户名是必须的</div> 
                </div> 
              </label> 
            </div> 
            <div class="item-input-inset"> 
              <label class="item-input-wrapper"> 
                <i class="icon ion-locked"></i> 
                <input type="password" name="password" ng-model="password" id="password" placeholder="密码" required> 
                <div ng-show="myForm.password.$invalid && submitted"> 
                  <div style="color:red" ng-show="myForm.password.$error.required">密码是必须的</div> 
                </div> 
              </label> 
            </div> 
          </div> 
          <div class="padding"> 
            <button class="button button-full button-dark" type="submit">登录</button> 
          </div> 
        </form> 
      </div> 
   </ion-content> 
  </ion-pane> 
  <script> 
 'use strict';   
 var myApp = angular.module('myApp',[]); 
myApp.controller('myCtrl',['$scope', '$http',function($scope, $http){ 
 // $scope.formModel = {}; 
 $scope.submitted = false; 
 $scope.onSubmit = function(){ 
  if ($scope.myForm.$valid) { 
    var param = { 
        User: $scope.user, 
        Pwd: $scope.password 
      } 
    $http.post('someurl',param) 
   .success(function(data){ 
    console.log(':)'); 
   }) 
   .error(function(data){ 
    console.log(':('); 
   }); 
  console.log(param); 
}else{ 
  $scope.submitted = true; 
} 
 } 
}]); 
  </script> 
 </body> 
</html> 

不填写信息登录就会如图所示:

注册:

<!DOCTYPE html> 
<html> 
<head> 
  <meta charset="utf-8"> 
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 
  <title></title> 
  <link href="lib/ionic/css/ionic.min.css" rel="external nofollow" rel="stylesheet"> 
  <link href="css/style.css" rel="external nofollow" rel="external nofollow" rel="stylesheet"> 
  <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above  
  <link href="css/ionic.app.css" rel="external nofollow" rel="external nofollow" rel="stylesheet">  
  --> 
  <!-- ionic/angularjs js --> 
  <script src="lib/ionic/js/ionic.bundle.js"></script> 
  <!-- cordova script (this will be a 404 during development) --> 
  <script src="cordova.js"></script> 
  <!-- your app's js --> 
  <script src="js/app.js"></script> 
  <script src="js/Register.js"></script> 
  <!-- <script src="js/controllers.js"></script> 
  <script src="js/services.js"></script> --> 
</head> 
<body ng-app="myApp" ng-controller="myCtrl"> 
  <!--  
   The nav bar that will be updated as we navigate between views.  
  --> 
  <!--  
   The views will be rendered in the <ion-nav-view> directive below  
   Templates are in the /templates folder (but you could also  
   have templates inline in this html file if you'd like).  
  --> 
  <ion-nav-view> 
    <ion-content> 
      <div class="bar bar-header "> 
        <div class="h1 title">用户注册</div> 
      </div> 
      <div class="content has-header"> 
        <form ng-submit="onSubmit(myForm.$valid)" name="myForm" novalidate> 
          <div class="list"> 
            <div class="item-input-inset"> 
              <label class="item-input-wrapper"> 
                <i class="icon ion-person"></i> 
                <input type="text" name="user" id="user" ng-model="user" placeholder="用户名" required> 
                <div ng-show="myForm.user.$invalid && submitted"> 
                  <div style="color:red" ng-show="myForm.user.$error.required">用户名是必须的</div> 
                </div> 
              </label> 
            </div> 
            <div class="item-input-inset"> 
              <label class="item-input-wrapper"> 
                <i class="icon ion-locked"></i> 
                <input type="password" name="password1" ng-model="password1" required id="password1" placeholder="密码"> 
                <div ng-show="myForm.password1.$invalid && submitted"> 
                  <div style="color:red" ng-show="myForm.password1.$error.required">密码是必须的</div> 
                </div> 
              </label> 
            </div> 
            <div class="item-input-inset"> 
              <label class="item-input-wrapper"> 
                <i class="icon ion-locked"></i> 
                <input type="password" name="password2" ng-model="password2" id="password2" required placeholder="确认密码"> 
                <div ng-show="myForm.password2.$invalid && submitted"> 
                  <div style="color:red" ng-show="myForm.password2.$error.required">确认密码是必须的</div> 
                </div> 
                <div ng-show="myForm.password2.$valid"> 
                  <div style="color:red" ng-show="password1!=password2">两次密码输入不一致</div> 
                </div> 
              </label> 
            </div> 
          </div> 
          <div class="padding"> 
            <button class="button button-full button-dark" type="submit">注册</button> 
          </div> 
    </form> 
  </div> 
   </ion-content> 
</ion-nav-view> 
 <script> 
   'use strict';   
 var myApp = angular.module('myApp',[]); 
myApp.controller('myCtrl',['$scope', '$http',function($scope, $http){ 
 // $scope.formModel = {}; 
 $scope.submitted = false; 
 $scope.onSubmit = function(){ 
  if ($scope.myForm.$valid) { 
    var param = { 
        User: $scope.user, 
        Pwd1: $scope.password1, 
        Pwd2:$scope.password2 
      } 
    $http.post('someurl',param) 
   .success(function(data){ 
    console.log(':)'); 
   }) 
   .error(function(data){ 
    console.log(':('); 
   }); 
  console.log(param); 
}else{ 
  $scope.submitted = true; 
} 
 } 
}]); 
  </script> 
</body> 
</html> 

不填写信息注册就会出现下图:

以上所述是小编给大家介绍的Ionic+AngularJS实现登录和注册带验证功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!


# ionic登录验证  # angularjs  # 注册验证  # 登录验证  # Angularjs中的验证input输入框只能输入数字和小数点的写法(推荐)  # Angularjs验证用户输入的字符串是否为日期时间  # AngularJS表单和输入验证实例  # AngularJS 输入验证详解及实例代码  # AngularJS中实现用户访问的身份认证和表单验证功能  # AngularJS身份验证的方法  # AngularJS 输入验证的原理解析  # 就会  # 小编  # 在此  # 两次  # 给大家  # 用户登录  # 所述  # 用户注册  # 给我留言  # 感谢大家  # 如图所示  # 疑问请  # 有任何  # stylesheet  # lib  # css  # ionic  # gulp  # sass 


相关文章: 七夕网站制作视频,七夕大促活动怎么报名?  建设网站制作价格,怎样建立自己的公司网站?  建站之星如何取消后台验证码生成?  网站网页制作电话怎么打,怎样安装和使用钉钉软件免费打电话?  济南企业网站制作公司,济南社保单位网上缴费步骤?  建站之星五站合一营销型网站搭建攻略,流量入口全覆盖优化指南  历史网站制作软件,华为如何找回被删除的网站?  惠州网站建设制作推广,惠州市华视达文化传媒有限公司怎么样?  如何在七牛云存储上搭建网站并设置自定义域名?  香港服务器部署网站为何提示未备案?  齐河建站公司:营销型网站建设与SEO优化双核驱动策略  开封网站制作公司,网络用语开封是什么意思?  建站之星后台密码遗忘如何找回?  音响网站制作视频教程,隆霸音响官方网站?  如何选择CMS系统实现快速建站与SEO优化?  如何设置并定期更换建站之星安全管理员密码?  如何在Golang中使用replace替换模块_指定本地或远程路径  如何在万网自助建站中设置域名及备案?  平台云上自助建站如何快速打造专业网站?  建站之星如何一键生成手机站?  建站之星CMS五站合一模板配置与SEO优化指南  ,南京靠谱的征婚网站?  美食网站链接制作教程视频,哪个教做美食的网站比较专业点?  单页制作网站有哪些,朋友给我发了一个单页网站,我应该怎么修改才能把他变成自己的呢,请求高手指点迷津?  如何用景安虚拟主机手机版绑定域名建站?  如何通过宝塔面板实现本地网站访问?  设计网站制作公司有哪些,制作网页教程?  香港服务器租用费用高吗?如何避免常见误区?  制作假网页,招聘网的薪资待遇,会有靠谱的吗?一面试又各种折扣?  建站之星如何助力企业快速打造五合一网站?  东莞专业制作网站的公司,东莞大学生网的网址是什么?  如何在腾讯云服务器上快速搭建个人网站?  制作网站建设的公司有哪些,网站建设比较好的公司都有哪些?  详解一款开源免费的.NET文档操作组件DocX(.NET组件介绍之一)  ,sp开头的版面叫什么?  弹幕视频网站制作教程下载,弹幕视频网站是什么意思?  东莞专业网站制作公司有哪些,东莞招聘网站哪个好?  临沂网站制作公司有哪些,临沂第四中学官网?  C++如何编写函数模板?(泛型编程入门)  网站代码制作软件有哪些,如何生成自己网站的代码?  如何在香港服务器上快速搭建免备案网站?  济南专业网站制作公司,济南信息工程学校怎么样?  如何快速建站并高效导出源代码?  如何用虚拟主机快速搭建网站?详细步骤解析  如何高效利用200m空间完成建站?  建站之星代理费用多少?最新价格详情介绍  自助网站制作软件,个人如何自助建网站?  如何选择可靠的免备案建站服务器?  如何将凡科建站内容保存为本地文件?  如何快速生成ASP一键建站模板并优化安全性? 

您的项目需求

*请认真填写需求信息,我们会在24小时内与您取得联系。