如何添加类Angular 2

时间:2016-10-19 12:46:11

标签: class angular binding

我试图只覆盖默认类的一部分(glyphicon-eye -...)。

使用此代码:

iddata()

我得到% create some dummy data time = rand(20,1); % irregular sampled measurements input = sin( 2*pi*time); % some input signal output = cos( 2*pi*time ); % some output signal % define new time vector and interpolate input and output data Ts = 0.01; % new sampling time in seconds newTime = min(time) : Ts : max(time); % new time vector inputInterp = interp1( time, input, newTime ) % interpolated input data outputInterp = interp1( time, output, newTime ) % interpolated output data % lets see what just happend figure plot( time,input,'o'), hold on plot(time,output,'ro'); plot( newTime, inputInterp, 'x') plot( newTime, outputInterp, 'rx') legend({'Original Input', 'Original Output', 'Interpolated Input', 'Interpolated Output'})

我怎样才能得到<i [class.glyphicon-eye-open] = "isOpen" class="glyphicon glyphicon-eye-close"></i>

1 个答案:

答案 0 :(得分:1)

使用ng-class代替

<i [ngClass]="{'glyphicon-eye-close': !isOpen, 'glyphicon-eye-open': isOpen}" class="glyphicon"></i>