Angular2以编程方式添加/删除类

Angular2以编程方式添加/删除类,angular,animate.css,Angular,Animate.css,在我的angular2登录表单中,如果用户插入了错误的凭据,我希望使用播放动画,因此我需要添加一个类,然后(?)删除它 我怎样才能做到这样的行为 非常感谢我在阅读官方文件时发现答案 这是我的工作实用程序类: export class JQueryUtils { public static animateCss (selector:string, animationName:string) { var jQueryElement = jQuery (selector

在我的angular2登录表单中,如果用户插入了错误的凭据,我希望使用播放动画,因此我需要添加一个类,然后(?)删除它

我怎样才能做到这样的行为


非常感谢

我在阅读官方文件时发现答案

这是我的工作实用程序类:

export class JQueryUtils
{
    public static animateCss (selector:string, animationName:string)
    {
        var jQueryElement = jQuery (selector);
        jQueryElement.addClass ('animated ' + animationName).one ('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend',
        function () {
            jQueryElement.removeClass ('animated ' + animationName);
        });
    }
}

在模板内部使用
ngClass
,在组件本身上,在
@component()
注释中使用
host:{'[class.someClass]':'someExpression'}
,仅举几个例子。

请提供一些代码来演示您试图完成的任务。有很多方法取决于你想要什么。