zhenghao 2019-06-27
1.ng-bind
使用给定的变量或表达式的值来替换 HTML 元素的内容
<p ng-bind="{{text}}"></p>
2.ng-blur
HTML 元素在失去焦点时需要执行的函数(<a>
, <input>
, <select>
, <textarea>
支持)
<input ng-blur="pay()" />
3.ng-checked/ng-disabled
ng-checked设置复选框(checkbox)或单选按钮(radio)的 checked 属性
ng-disabled表达式返回 true 则表单字段将被禁用(<input>
, <select>
, 或 <textarea>
)
<input type="checkbox|radio" ng-checked="flag" ng-disabled="flag"></input> //flag为布尔类型
4.ng-class
给 HTML 元素动态绑定一个或多个 CSS 类。
//写法一 <div ng-class="home"></div> //写法二 <div ng-class="{'red':flag,'green':'!flag'}"></div> //flag为true则添加red类名,false则添加green类名
5.ng-click
<button ng-click="addpay($event)">OK</button> //$event为当前元素的多种属性
6.ng-repeat
<div ng-repeat="(index,item) in list"></div> // 每项值:{{item}} // 下标:{{index}}
<a>
元素指定链接<select>
列表中指定 <options>
详情参考:http://www.runoob.com/angular...
二:angular指令imageUrl 属性:
<img [src]="imageUrl">
[disabled]当组件为 isUnchanged( 未改变 ) 时禁用一个按钮:
<button [disabled]="isUnchanged">按钮是禁用的</button>
设置指令的属性:
<div [ngClass]="classes">[ngClass]绑定到classes 属性</div>
表格的colspan/rowspan
<table border=1> <tr><td [attr.colspan]="1 + 1">One-Two</td></tr> <tr><td>Five</td><td>Six</td></tr> </table>
[(NgModel)]
<input [(ngModel)]="currentUser.firstName">
NgIf
<div *ngIf="currentUser">Hello,{{currentUser.firstName}}</div>
NgFor
<div *ngFor="let user of users; let i=index">{{i + 1}} - {{user.fullName}}</div>
(click)
<button type="submit" class="btn btn-primary" (click)="hide()">确定</button>
[(checked)]
<input type="checkbox" [(checked)]="checkflag">
common
NgClass NgComponentOutlet NgForOf NgIf NgPlural NgPluralCase NgStyle NgSwitch NgSwitchCase NgSwitchDefault NgTemplateOutlet
forms
CheckboxControlValueAccessor CheckboxRequiredValidator DefaultValueAccessor EmailValidator FormArrayName FormControlDirective FormControlName FormGroupDirective FormGroupName MaxLengthValidator MinLengthValidator NgControlStatus NgControlStatusGroup NgForm NgModel NgModelGroup NgSelectOption PatternValidator RadioControlValueAccessor RequiredValidator SelectControlValueAccessor SelectMultipleControlValueAccessor
router
RouterLink RouterLinkActive RouterLinkWithHref RouterOutlet
问题描述在编写导入指令的时候,需要将函数绑定到指令中,并传入一个参数。<button ng-hide="importing" class="btn btn-warning btn-sm" type="