// project.component.ts
import {trigger, state, style, animate, transition} from '@angular/animations';
@Component({
selector: 'projects',
template: require('./projects.html'),
styleUrls: ['./projects.css'],
providers: [ProjectService],
animations: [
trigger('projectIn', [
state('active', style({transform: 'translateX(0)', opacity: 1})),
transition('void => *', [
style({transform: 'translateX(500px)', opacity: 0}), animate('1s ease-in-out')
])
]),
]
})
export class ProjectComponent{
state: tring = 'active';
}
// project.component.ts
import {trigger, state, style, animate, transition} from '@angular/animations';
@Component({
selector: 'projects',
template: require('./projects.html'),
styleUrls: ['./projects.css'],
providers: [ProjectService],
animations: [
trigger('projectIn', [
state('active', style({transform: 'translateX(0)', opacity: 1})),
transition('void => *', [
style({transform: 'translateX(500px)', opacity: 0}), animate('1s ease-in-out')
])
]),
]
})
export class ProjectComponent{
state: tring = 'active';
}
<tr *ngFor="let project of projects" [@projectIn]="state"> <tr *ngFor="let project of projects" [@projectIn]="state">
<button type="button" class="btn searchbtn btn-primary"(click)="search(); getProjects(pagecount.value, 1, projectName.value)"><i [ngClass]='searchClass'>{{searchValue}}</i></button>
// search 按钮
<button (click)="reset(); getProjects();projectName.value = '';" type="button" class="btn btn-primary"><i [ngClass] = "resetClass"></i></button>
// reset 按钮
<button type="button" class="btn searchbtn btn-primary"(click)="search(); getProjects(pagecount.value, 1, projectName.value)"><i [ngClass]='searchClass'>{{searchValue}}</i></button>
// search 按钮
<button (click)="reset(); getProjects();projectName.value = '';" type="button" class="btn btn-primary"><i [ngClass] = "resetClass"></i></button>
// reset 按钮
resetClass: string = 'fa fa-repeat';
searchClass: string = '';
searchValue: string = '搜索';
reset() {
this.resetClass = 'fa fa-repeat fa-spin';
setTimeout(() => this.resetClass = "fa fa-repeat", 2000);
}
search() {
this.searchValue = '';
this.searchClass = 'fa fa-repeat fa-spin';
setTimeout(() => {
this.searchClass = '';
this.searchValue = '搜索';
}, 2000)
}
resetClass: string = 'fa fa-repeat';
searchClass: string = '';
searchValue: string = '搜索';
reset() {
this.resetClass = 'fa fa-repeat fa-spin';
setTimeout(() => this.resetClass = "fa fa-repeat", 2000);
}
search() {
this.searchValue = '';
this.searchClass = 'fa fa-repeat fa-spin';
setTimeout(() => {
this.searchClass = '';
this.searchValue = '搜索';
}, 2000)
}
// 直接在getprojects里面加上如下代码
swal({
title: 'loading',
type: 'success',
timer: 1000,
showConfirmButton: false,
}).catch(()=>{});
//即每次获取数据后触发弹窗动画。
// 直接在getprojects里面加上如下代码
swal({
title: 'loading',
type: 'success',
timer: 1000,
showConfirmButton: false,
}).catch(()=>{});
//即每次获取数据后触发弹窗动画。
import {QbcSearchComponent} from './component/qbc-search/qbc-search.component';
import {QbcResetComponent} from './component/qbc-reset/qbc-reset.component';
declarations: [ QbcSearchComponent,QbcResetComponent]
import {QbcSearchComponent} from './component/qbc-search/qbc-search.component';
import {QbcResetComponent} from './component/qbc-reset/qbc-reset.component';
declarations: [ QbcSearchComponent,QbcResetComponent]
//qbc-search.component.ts 添加如下代码
import { Component, Output, EventEmitter} from '@angular/core';
import swal from 'sweetalert2';
@Component({
selector: 'qbc-search',
template: require('./qbc-search.html'),
})
export class QbcSearchComponent {
@Output() searchEmitter = new EventEmitter();
searchClass: string = '';
searchValue: string = '搜索';
constructor() {}
search(value) {
this.searchValue = '';
this.searchClass = 'fa fa-repeat fa-spin';
setTimeout(() => {
this.searchClass = '';
this.searchValue = '搜索';
}, 2000)
this.searchEmitter.emit(value);
swal({
title: 'loading',
type: 'success',
timer: 1000,
showConfirmButton: false,
}).catch(()=>{});
}
}
//qbc-search.component.ts 添加如下代码
import { Component, Output, EventEmitter} from '@angular/core';
import swal from 'sweetalert2';
@Component({
selector: 'qbc-search',
template: require('./qbc-search.html'),
})
export class QbcSearchComponent {
@Output() searchEmitter = new EventEmitter();
searchClass: string = '';
searchValue: string = '搜索';
constructor() {}
search(value) {
this.searchValue = '';
this.searchClass = 'fa fa-repeat fa-spin';
setTimeout(() => {
this.searchClass = '';
this.searchValue = '搜索';
}, 2000)
this.searchEmitter.emit(value);
swal({
title: 'loading',
type: 'success',
timer: 1000,
showConfirmButton: false,
}).catch(()=>{});
}
}
//qbc-search.html
<div class="input-group">
<input type="text" placeholder="请输入名称" class="searchinput form-control" #name>
<span class="input-group-btn"><button type="button" class="btn searchbtn btn-primary"
(click)="search(name.value);"><i [ngClass]='searchClass'>{{searchValue}}</i></button></span>
</div>
//qbc-search.html
<div class="input-group">
<input type="text" placeholder="请输入名称" class="searchinput form-control" #name>
<span class="input-group-btn"><button type="button" class="btn searchbtn btn-primary"
(click)="search(name.value);"><i [ngClass]='searchClass'>{{searchValue}}</i></button></span>
</div>
//projects.html //将原先的搜索框代码部分用qbc-search代替。 <qbc-search (searchEmitter)=search(pagecount.value,1,$event)></qbc-search> //projects.html //将原先的搜索框代码部分用qbc-search代替。 <qbc-search (searchEmitter)=search(pagecount.value,1,$event)></qbc-search>
//projects.component.ts
// 其实也可以直接在模板中调用getProjects方法,差不多。一个是后期要修改模板,一个是要修改TS文件。
search(pageSize, page, name) {
this.getProjects(pageSize, page, name);
}
//projects.component.ts
// 其实也可以直接在模板中调用getProjects方法,差不多。一个是后期要修改模板,一个是要修改TS文件。
search(pageSize, page, name) {
this.getProjects(pageSize, page, name);
}
// 先试试可不可以放入app.component.ts
animations: [
trigger('fadeIn', [
state('active', style({transform: 'translateX(0)', opacity: 1})),
transition('void => *', [
style({transform: 'translateX(500px)', opacity: 0}), animate('1s ease-in-out')
])
]),
]
// 先试试可不可以放入app.component.ts
animations: [
trigger('fadeIn', [
state('active', style({transform: 'translateX(0)', opacity: 1})),
transition('void => *', [
style({transform: 'translateX(500px)', opacity: 0}), animate('1s ease-in-out')
])
]),
]
//projects.html
[@fadeIn] = "state"
// error The provided animation trigger "c1#fadeIn" has not been registered!
//projects.html
[@fadeIn] = "state"
// error The provided animation trigger "c1#fadeIn" has not been registered!
.fadeIn{
animation: fadeIn ease-in-out 1.5s 1; // 参数依次为: 动画名称 缓动函数 动画时间 动画运行次数
}
@keyframes fadeIn{
0% {
opacity: 0;
transform: translateX(500px);
}
100%{
opacity: 1;
transform: translateX(0);
}
}
.fadeIn{
animation: fadeIn ease-in-out 1.5s 1; // 参数依次为: 动画名称 缓动函数 动画时间 动画运行次数
}
@keyframes fadeIn{
0% {
opacity: 0;
transform: translateX(500px);
}
100%{
opacity: 1;
transform: translateX(0);
}
}
//projects.component.ts styleUrls: ['./projects.css', '../animation.css'] //projects.html <tr *ngFor="let project of projects" class="fadeIn"> //projects.component.ts styleUrls: ['./projects.css', '../animation.css'] //projects.html <tr *ngFor="let project of projects" class="fadeIn">
// projects.html // bootstrap库帮你写好了,填写class就好 <tr *ngFor="let project of projects" class="animated fadeInRight"> // projects.html // bootstrap库帮你写好了,填写class就好 <tr *ngFor="let project of projects" class="animated fadeInRight">
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有