全网整合营销服务商

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

免费咨询热线: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 


相关文章: 如何选择适配移动端的WAP自助建站平台?  武清网站制作公司,天津武清个人营业执照注销查询系统网站?  家具网站制作软件,家具厂怎么跑业务?  Thinkphp 中 distinct 的用法解析  小程序网站制作需要准备什么资料,如何制作小程序?  如何用腾讯建站主机快速创建免费网站?  如何快速搭建自助建站会员专属系统?  公司门户网站制作流程,华为官网怎么做?  北京网站制作网页,网站升级改版需要多久?  如何获取上海专业网站定制建站电话?  如何在Mac上搭建Golang开发环境_使用Homebrew安装和管理Go版本  在线流程图制作网站手机版,谁能推荐几个好的CG原画资源网站么?  清除minerd进程的简单方法  如何基于PHP生成高效IDC网络公司建站源码?  如何彻底卸载建站之星软件?  北京网站制作费用多少,建立一个公司网站的费用.有哪些部分,分别要多少钱?  在线制作视频的网站有哪些,电脑如何制作视频短片?  早安海报制作网站推荐大全,企业早安海报怎么每天更换?  建站之星备案流程有哪些注意事项?  如何撰写建站申请书?关键要点有哪些?  如何快速搭建高效WAP手机网站?  西安大型网站制作公司,西安招聘网站最好的是哪个?  香港网站服务器数量如何影响SEO优化效果?  网站制作与设计教程,如何制作一个企业网站,建设网站的基本步骤有哪些?  外贸公司网站制作哪家好,maersk船公司官网?  详解jQuery停止动画——stop()方法的使用  GML (Geography Markup Language)是什么,它如何用XML来表示地理空间信息?  如何在Golang中实现微服务服务拆分_Golang微服务拆分与接口管理方法  网站制作新手教程,新手建设一个网站需要注意些什么?  如何高效搭建专业期货交易平台网站?  整人网站在线制作软件,整蛊网站退不出去必须要打我是白痴才能出去?  如何用好域名打造高点击率的自主建站?  公众号网站制作网页,微信公众号怎么制作?  建站之星五站合一营销型网站搭建攻略,流量入口全覆盖优化指南  建站VPS配置与SEO优化指南:关键词排名提升策略  ui设计制作网站有哪些,手机UI设计网址吗?  公司网站制作需要多少钱,找人做公司网站需要多少钱?  建站之星安全性能如何?防护体系能否抵御黑客入侵?  常州自助建站工具推荐:低成本搭建与模板选择技巧  如何通过二级域名建站提升品牌影响力?  专业的网站制作设计是什么,如何制作一个企业网站,建设网站的基本步骤有哪些?  如何快速搭建响应式可视化网站?  长沙做网站要多少钱,长沙国安网络怎么样?  公司门户网站制作公司有哪些,怎样使用wordpress制作一个企业网站?  大连网站制作公司哪家好一点,大连买房网站哪个好?  如何续费美橙建站之星域名及服务?  宿州网站制作公司兴策,安徽省低保查询网站?  海南网站制作公司有哪些,海口网是哪家的?  广州商城建站系统开发成本与周期如何控制?  c# await 一个已经完成的Task会发生什么 

您的项目需求

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