对文本框的一点小应用!

1.对用户名进行验证,把它设置为必填项:
    %form(name="myform" ng-controller="userctrl")
      %input(name="input" ng-model="username" required )
         用户名:
      %span(class="error" ng-show="myform.input.$error.required")
         必填!
    function userctrl($scope)
    {
     $scope.username="user";
     }
     angular.module("App",[] );  //必须要写,否者无法运行
 


知识点1:angular.module  
    The angular.module is a global place for creating, registering and retrieving(检索) Angular modules.
   (1)// Create a new module
    var myModule = angular.module('myModule', [ ]);
 
      // register a new service
    myModule.value('appName', 'MyCoolApp'); 
  
知识点2:ng-model
     The ngModel directive binds(捆绑,约束) an       input,select, textarea (or custom form control)       to a property(性能) on the scope using NgModelController, which is created and exposed by this directive.


知识点3;ng-model ,ng-show ,ng-hide  ,ng-disabled 混搭使用
    (1) <div>                                                                                              (2)
           <input type="checkbox" ng-model="check">                                  <input ng-model="input">
          <div ng-show="check">                                                      
          show:                                                                                                         <div ng-disabled="!input">  
            <div>hello</div>
          </div>
           <div ng-hide="check">
          show:            
            <div>bye bye</div>
          </div>
      </div>      //相应的样式自己添加吧!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值