在我的角模板我有這段代碼:引導數據切換屬性禁用變化事件 - 角
<div class = "btn-group" data-toggle="buttons">
<input type="text" class = "form-control" [(ngModel)]="siteFilter[filterType]" placeholder="Refine Search">
<label class="btn btn-default">
<input type="radio" (change)="changeFilter('1')" autocomplete="off">1
</label>
<label class="btn btn-default active">
<input type="radio" (change)="changeFilter('2')" autocomplete="off" checked>2
</label>
<label class="btn btn-default">
<input type="radio" (change)="changeFilter('3')" autocomplete="off">3
</label>
</div>
當我使用data-toggle="buttons"
屬性,我的(change)="changeFilter()
甚至沒有觸發。如何保持data-toggle
功能,並在radio
按下時觸發change
事件?
您可以考慮使用[NG-引導(https://ng-bootstrap.github.io/#/home)(Angular 4 + Bootstrap 4)。 [NgbRadioGroup](https://ng-bootstrap.github.io/#/components/buttons/api)可以爲您提供您正在尋找的功能。請參閱[代碼示例](https://ng-bootstrap.github.io/#/components/buttons/examples)。 – ConnorsFan
是的,事後我應該從一開始就使用'ng-bootstrap',但我寧願現在不必轉換整個應用程序。有沒有一種方法可以使用'ng-bootstrap'而不影響我的Bootstrap 3元素的其餘部分? – ecain
我對Bootstrap沒有太多的經驗,但我懷疑你可以將Bootstrap 3(CSS + jQuery)與ng-bootstrap(Bootstrap 4 CSS,沒有jQuery)混合使用。混合這兩個可能比轉換爲ng-bootstrap和[升級到Bootstrap 4](https://v4-alpha.getbootstrap.com/migration/)更復雜。 – ConnorsFan