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> //相应的样式自己添加吧!
%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> //相应的样式自己添加吧!