我有条件地生成段按钮,如何更改单击的按钮颜色:
// import reflect metadata shim
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
// Angular and application imports
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
import { ViewEncapsulation } from '@angular/core';
// load the editor in the next frame
requestAnimationFrame(() => {
if (window.Zone) {
bootstrap();
}
else {
import('zone.js/dist/zone') // <-- PROBLEM HERE
.then(bootstrap);
}
});
// bootstraps the editor
function bootstrap() {
// add the root component to the DOM
const root = document.createElement('efe-root');
document.body.appendChild(root);
// bootstrap the Angular app
platformBrowserDynamic()
.bootstrapModule(AppModule, {
defaultEncapsulation: ViewEncapsulation.Native
})
.then(() => console.debug('Exponea Free Editor has bootstrapped'));
}
如果我在<ion-segment *ngIf="menu" [(ngModel)]="apps">
<ion-segment-button *ngFor="let item of menu; let i = index" value="{{item .key}}"
[ngClass]="{active: i === activeIndex}" (click)="changeTab(item.key); setActiveIndex(i)"
style="display:block;" >
{{item?.name}}
</ion-segment-button>
</ion-segment>
上应用[ngStyle]="{'background-color': this.buttonColor}"
,那么它会反映所有按钮,我只想更改所点击的按钮的颜色