ずにhtml要素を削除し、私は、あなたがアンギュラ - クラス
<my-component myClass="hello-class"></my-component>
とコンポーネントのHTMLで、HTMLにクラスを渡すことができコンポーネントを持って
<div class="{{myClass}}"> Div with the class</div>
<div>A div without the class</div>
しかし、場合によってはどこがありますクラスをmyClass
に渡すことはできません。そのようなシナリオでは
、私は、ユーザーからのクラスの入力を必要とdiv要素を削除したい、
<my-component></my-component>
(何のクラスは渡されません)
だけではありませんdiv要素は必要ありません示していクラス。
<div>A div without the class</div>
私はこれを行うには、HTMLに渡すことができる条件があり、
例:
<div *ngIf="myClass-is-not-empty" class="{{myClass}}"> Div with the class</div>
<div>A div without the class</div>