Sam*_*Sam 6 angular2-router3 angular
我想我已经连接了基本的动画部分,我只需要知道要处理的事件.理想情况下,我想要一个我可以在导航级别使用的解决方案,所以我可以包装我的所有组件,但一个简单的页面加载示例就足够了,非常感激.我在SO上发现了其他一些相关问题,但它们似乎没有回答我的具体问题或过时:
使用Angular 2.0路由器和组件接口承诺的路由组件页面过渡动画的Angular 2"动画幻灯片"
这是我到目前为止:
html文件
<article @heroState="componentState">
<p>article element should fade in/out</p>
</article>
Run Code Online (Sandbox Code Playgroud)
零件
@Component({
selector: 'blog-about',
templateUrl: './app/about/about.html',
animations: [
trigger('heroState', [
state('active', style({
backgroundColor: 'blue',
transform: 'scale(1)'
})),
state('inactive', style({
backgroundColor: 'green',
transform: 'scale(1.1)'
})),
transition('active => inactive', animate('1000ms ease-in')),
transition('inactive => active', animate('1000ms ease-out'))
])
]
})
export class About implements OnInit, OnDestroy {
public componentState: string;
public Title: string
constructor() {
this.Title = "this is about";
}
ngOnInit()
{
this.componentState = 'inactive';
}
ngOnDestroy()
{
}
}
Run Code Online (Sandbox Code Playgroud)
小智 1
您确定您没有参考答案: https: //stackoverflow.com/a/40077108/6678754 和 plunker: https: //embed.plnkr.co/Vral6cwlaQz27MUQNkVg/吗?这应该对你有用,再检查一下。
不过,您还有另一种选择:在导入 about 组件的父级中使用动画,如下所示:
<blog-about [@heroState]="activeRouteVar"></blog-about>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1310 次 |
| 最近记录: |