1

When I click to edit I call a component for the editing so in the component I cannot click anything and hast background black that its oke, but I want for each ID what I select to edit to be active or just to have background white or z-index.

This is my HTML

<div class="name-block" [ngClass]="'name-block-width-' + valueItem.level"
  [ngClass]="{active: activeSelected === valueItem.id, 'name-block': true}" (click)="toggleExpand()">
</div>

This is the css

.name-block {
  @extend %common-block;
  @include center(false, true);
  @include justify-content(space-between);
  margin-left: 1px;
  padding-left: 10px;
  &.active {
    z-index: 950;
  }

  div.businessId {
    @extend %flexbox;
    @include center(false, true);
    border-left: solid thin $border-color;
    padding: 0 5px;
    height: 100%;
  }
}

@for $i from 1 through 7 {
  .name-block-width-#{$i} {
    width: 500px - (($i - 1) * 50px);
  }
}

And this is the TS when I try to edit

edit(editOptions: EditViOptions) {
  this.showChild = !this.showChild;
  if (editOptions.valueItem || editOptions.appendToParentId) {
    this.dataToPass = editOptions;
    this.activeSelected = editOptions.valueItem.id;

  } else {
    this.activeSelected = null;
  }
}
Walter Luszczyk
  • 1,155
  • 2
  • 18
  • 34
Abedin.Zhuniqi
  • 855
  • 5
  • 20
  • 41

3 Answers3

2

Use it like this

<div [class]="'name-block name-block-width-' + valueItem.level"  [ngClass]="{'active': activeSelected === valueItem.id}" (click)="toggleExpand()">abc</div>
Nandita Sharma
  • 12,889
  • 2
  • 20
  • 29
1

You can use [ngClass] only once in each selector:

do it as below:

 [ngClass]="'name-block-width-' + valueItem.leve + ' '+ {active: activeSelected === valueItem.id, 'name-block': true}" 
לבני מלכה
  • 15,403
  • 2
  • 20
  • 41
0

You can do it like this

 <div class="name-block" 
  [ngClass]="{'name-block-width-' + valueItem.level:'name-block-width-' + valueItem.level,
                  active: activeSelected === valueItem.id,  'name-block': true }" 
 (click)="toggleExpand()">
Muhammed Albarmavi
  • 21,124
  • 5
  • 55
  • 80