1
球員我有我的模板中的「跨度」標籤,將顯示是否有某些陳述是真實的......我在它上面應用了一些動畫,但它沒有轉換就執行它..它會失去轉換原因?角度4動畫轉換
component.ts
@Component({
selector: 'app-user-new',
templateUrl: './user-new.component.html',
styleUrls: ['./user-new.component.css'],
styles: [`span{position: absolute}`],
animations: [
trigger('heroState', [
state('inactive', style({
backgroundColor: '#eee',
transform: 'scale(1)'
})),
state('active', style({
backgroundColor: '#cfd8dc',
transform: 'scale(1.1)',
bottom: '100px'
})),
transition('inactive <=> active', animate('2s ease-in'))
])
]
})
state:string = "active";
我的HTML
<h3>user new component</h3>
<form
[formGroup]="heroUser"
(ngSubmit)="create(heroUser.value)"
>
<div></div>
<span [@heroState]="state" *ngIf="heroUser.controls['name'].touched && !heroUser.controls['name'].valid && heroUser.controls['name'].value != ''">incorrect data inserted</span>
<span *ngIf="heroUser.controls['name'].touched && heroUser.controls['name'].value == ''">field should not empety</span>
<span *ngIf="heroUser.controls['name'].valid">nice!</span>
<input type="text" name="name" formControlName="name">
<input type="text" name="username" formControlName="username">
<input type="text" name="email" formControlName="email">
<input type="text" name="phone" formControlName="phone">
<input type="submit" [disabled]="!heroUser.valid">
</form>