Вы должны будете использовать [attr.data-target]="'#MyModal'+task.id"
... с учетом структуры данных:
this.data = [
{id:1, buttonLabel: 'test label 1', modalBody: 'Demo Modal body contents #1' }
,{id:2, buttonLabel: 'test label 2', modalBody: 'Demo Modal body contents #2' }
,{id:3, buttonLabel: 'test label 3', modalBody: 'Demo Modal body contents #3' }
];
Это будет HTML:
<div *ngFor="let task of data ; let i = index" [attr.data-index]="i">
<button type="button" class="btn btn-primary" data-toggle="modal" [attr.data-target]="'#MyModal'+task.id">
Open modal
</button>
</div>