Вы можете использовать массив, чтобы сохранить отключенные индексы или добавить флаг отключения в опцию вашей кнопки.
Использовать отключенный массив
https://stackblitz.com/edit/angular-sef3nc?file=src%2Fapp%2Fapp.component.html
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
disabledButtons= [1, 2]
buttons = [
{
actionName: 'action1',
title: 'button1'
},
{
actionName: 'action2',
title: 'button2'
},
{
actionName: 'action3',
title: 'button3'
}
]
callAction(action) {
console.log(action)
}
}
<li *ngFor="let button of buttons; let i = index">
<button class="btn btn-lg btn-primary"
[disabled]="disabledButtons.indexOf(i) !== -1"
(click)="callAction(button.actionName)">
{{ button.title }}
</button>
</li>
Используйте флаг в опции
https://stackblitz.com/edit/angular-zvbepr?file=src%2Fapp%2Fapp.component.html
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
buttons = [
{
actionName: 'action1',
title: 'button1',
disabled: true
},
{
actionName: 'action2',
title: 'button2',
disabled: true
},
{
actionName: 'action3',
title: 'button3',
disabled: false
}
]
callAction(action) {
console.log(action)
}
}
<li *ngFor="let button of buttons; let i = index">
<button class="btn btn-lg btn-primary"
[disabled]="button.disabled"
(click)="callAction(button.actionName)">
{{ button.title }}
</button>
</li>