Each trigger starts with an “undefined” state or a “void” state which doesn’t match any of your currently defined states. You have to be aware of when you’re in that state so that you don’t stumble on any undesired behaviors. This is especially important if your transitions cover “*”/all states because “void” is part of “all”.

import {Component, trigger, state, style, transition, animate} from "@angular/core";
@Component({
selector: 'app',
animations:[
trigger('signal', [
state('void', style({
'transform':'translateY(-100%)'
})),
state('go', style({
'background-color':'green',
'height':'100px'
})),
state('stop', style({
'background-color':'red',
'height':'50px'
})),
transition('* => *', animate())
])
],
styles:[`
.traffic-light{
width: 100px;
height: 100px;
background-color: black;
}
`],
template: `
<div
[@signal]="signal"
class="traffic-light"
*ngIf="isHere"
> </div>
<button (click)="onGoClick()">Go</button>
<button (click)="onStopClick()">Stop</button>
<hr>
<button (click)="onToggleClick()">Toggle</button>
`
})
export class AppComponent {
signal;
isHere = false; onGoClick(){
this.signal = 'go';
} onStopClick(){
this.signal = 'stop';
} onToggleClick(){
this.isHere = !this.isHere;
}
}

[Angular2 Animation] Control Undefined Angular 2 States with void State的更多相关文章

  1. [Angular2 Form] Understand the Angular 2 States of Inputs: Pristine and Untouched

    Angular 2’s ngModel exposes more than just validity, it even gives you the states of whether the inp ...

  2. [Angular2 Animation] Use Keyframes for Fine-Tuned Angular 2 Animations

    When easing isn’t enough to get the exact animation you want, you can leverage keyframes to define a ...

  3. [Angular2 Animation] Delay and Ease Angular 2 Animations

    By default, transitions will appear linearly over time, but proper animations have a bit more custom ...

  4. [Angular2 Router] Exiting an Angular 2 Route - How To Prevent Memory Leaks

    In this tutorial we are going to learn how we can accidentally creating memory leaks in our applicat ...

  5. [Angular2 Router] Understand the Angular 2 Base href Requirement

    The <base href=”/”/> you define will determine how all other assets you plan on loading treat ...

  6. [Angular2 Router] Lazy Load Angular 2 Modules with the Router

    Angular 2 lazy loading is a core feature of Angular 2. Lazy loading allows your application to start ...

  7. [Angular2 Animation] Basic animation

    @Component({ selector: 'app-courses', templateUrl: './courses.component.html', styleUrls: ['./course ...

  8. [Angular] How to get Store state in ngrx Effect

    For example, what you want to do is navgiate from current item to next or previous item. In your com ...

  9. Angular 2 to Angular 4 with Angular Material UI Components

    Download Source - 955.2 KB Content Part 1: Angular2 Setup in Visual Studio 2017, Basic CRUD applicat ...

随机推荐

  1. linux 下find---xargs以及find--- -exec结合使用

    例:删除/home/raven下,包括子目录里所有名为abc.txt的文件: find /home/raven -name abc.txt | xargs rm -rf 如果不使用xargs,则为: ...

  2. 托管非托管Dll动态调用

    原文:托管非托管Dll动态调用 最近经常看到有人问托管非托管Dll调用的问题.对于动态库的调用其实很简单.网上很多代码都实现了Dll的静态调用方法.我主要谈论下动态库的动态加载. 对于托管动态库,实现 ...

  3. Android屏幕分辨率获取方法--源码剖析

    本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 在适配的过程中,有时我们会用到屏幕宽高,那么如何获得屏幕的分辨率? 方法有两种: 第一种是通过Win ...

  4. JavaWeb学习笔记:Tomcat

    Tomcat 开源的 Servlet 容器. 部署并启动 tomcat server. 解压 apache-tomcat-6.0.16.zip 到一个非中文文件夹下. 配置一个环境变量. java_h ...

  5. php实现合并多个数组

    php实现合并多个数组 一.总结 1.就是想c++和java里面合并数组那么简单,就是把多个数组的值赋值个一个啊,很简单 二.代码 合并多个数组,不用array_merge(),题目来于论坛. 思路: ...

  6. 41.C++多线程生产消费者模型

    #include <iostream> #include <thread> #include <mutex> #include <condition_vari ...

  7. Linux系统捕获数据包流程

    Linux系统捕获数据包流程 为了提高数据包的捕获效率,瓶颈问题是一个需要非常关注的焦点.减少在捕获数据包过程中的瓶颈,就能够提高数据包捕获的整体性能.下面本文将以Linux操作系统为平台,分析捕获数 ...

  8. File Upload with Jersey

    package com.toic.rest; import java.io.File; import java.io.FileOutputStream; import java.io.IOExcept ...

  9. BZOJ2754: [SCOI2012]喵星球上的点名(AC自动机/后缀自动机)

    Description a180285幸运地被选做了地球到喵星球的留学生.他发现喵星人在上课前的点名现象非常有趣.   假设课堂上有N个喵星人,每个喵星人的名字由姓和名构成.喵星球上的老师会选择M个串 ...

  10. C#调用C++生成的动态链接库DLL

    一.背景 由于要使用C#写app,所以要把C++生成的DLL在C#中调用,所以就涉及怎样去调用外部的dll问题. 二.C#调用外部DLL 首先先看下C#调用外部DLL的代码 using System. ...