Я пытаюсь изменить цвет кнопки на нажатой кнопке или события клика. Даже цвет фона границы также подойдет. Но этот фрагмент кода не применяет требуемые цвета. Кажется, метод вызывается, но цвета не применяются.
Кнопка-radioreactive.html
<code><form [formGroup]="radioGroupForm">
<div class="btn-group btn-group-toggle" ngbRadioGroup name="radioBasic" formControlName="model">
<label ngbButtonLabel class="btn-primary">
<input ngbButton type="radio" [value]="1" > Left (pre-checked)
</label>
<label #value1 ngbButtonLabel class="btn-primary" (click)="call()">
<input ngbButton type="radio" value="middle"> Middle
</label>
<label ngbButtonLabel class="btn-primary">
<input ngbButton type="radio" [value]="false"> Right
</label>
</div>
</form>
<hr>
<pre>{{radioGroupForm.value['model']}}
кнопка-radioreactive.ts
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import {ElementRef} from '@angular/core';
import { ViewChild } from '@angular/core/';
@Component({
selector: 'ngbd-buttons-radioreactive',
templateUrl: './buttons-radioreactive.html',
styleUrls: ['./buttons-radioreactive.css']
})
export class NgbdButtonsRadioreactive implements OnInit {
@ViewChild('value1')el:ElementRef;
public radioGroupForm: FormGroup;
constructor(private formBuilder: FormBuilder) {}
ngOnInit() {
this.radioGroupForm = this.formBuilder.group({
'model': 1
});
}
call(){
console.log("Called before")
this.el.nativeElement.color="orange";
console.log("Called after")
}
}
кнопка-radioreactive.css
.pressed {
border-color: #ff9800;
color: orange;
}
.un-pressed {
border-color: #ffffff;
color: white;
}