Reputation: 4262
Is it possible to use an If statement
to set the column width of the div
? I have got different div
elements like this:
<div class="col-xs-3">
<select class="form-control" [(ngModel)]="selectedPrototypeSelector" (ngModelChange)="onPrototypeChange()">
<option *ngFor="#p of prototypes" [value]="p.selector">
{{ p.selectorName }}
</option>
</select>
</div>
<div class="col-xs-1" *ngIf="prototype?.valueType === 'Set'">
<p class="text-center">If</p>
</div>
How can I change the col-xs-3
above to col-xs-2
for example when prototype?.valueType === 'Set'
Upvotes: 2
Views: 1759
Reputation: 657356
Use ngClass
:
<div [ngClass]="{
'col-xs-3': prototype?.valueType !== 'Set',
'col-xs-2': prototype?.valueType === 'Set'}">
See also https://angular.io/docs/ts/latest/api/common/NgClass-directive.html
Upvotes: 6
Reputation: 202196
I would leverage NgClass
for this:
<div [ngClass]="{'col-xs-2': prototype?.valueType === 'Set', 'col-xs-3': 'prototype?.valueType !== 'Set''}">
Upvotes: 2