The method of angular study notes, conditional, forms, two-way data binding

1. Define a class method below

getmsg(){
  alert("this.msg")
}
setData () {
  the this .username = " is assigned to a new username value change triggers this method username " 
}

Execute a method:

<the Button class = " the Button " (the Click) = " getmsg () " > Click the button to trigger the event </ button>
<Button class = " Button " (the Click) = " the setData () " > Click setting data </ button>

2. Analyzing conditions (two way)

<= P * ngIf " List.length>. 3 " > It is determined whether ngIF </ P> 
<P = Template " ngIf List.length>. 3 " > This is </ p ngIF determines whether>

3. Form

<input type="text" (keyup)="keyUpFn($event)"/> 事件对象
keyUpFn(e){
  console.log(e)
}

4. The two-way data binding (ngModel),

import { FormsModule } from '@angular/forms';
<input type ="text"[(ngModel)]="inputValue">

 

Guess you like

Origin www.cnblogs.com/zhaoqiusheng/p/11089935.html