Angular update componentu

0

Witam, mam problem z odświeżeniem componentu, który waliduje inputa.

export class Child {

    public inputClass: string = "form-control";

    public refreshClass(): void {
        this.inputClass = "form-control is-valid";
    }

}

export class Parent {
    
    constructor() {
        // tutaj oczywiscie obiekt child
    }

    private SomeMethod() {
        this.child.refreshClass();
    }
}

W klasie child w html jest input, który ma binda z polem inputClass - czyli wartość tego pola jest klasą tamtego inputa. Wszystko działą jak należy, jeśli metoda refreshClass() jest wywołana z kontekstu komponentu child (onFocus np). Jednak SomeMethod() w klasie parent, mimo, że przechodzi poprawnie i przypisuje wartość, to nie aktualizuje html komponentu child.

0

Ale strasznie dziwnie to wygląda. Jak mniemam, to jest jakiś skrawek problemu - mógłbyś udostępnić większy fragment kodu? Możesz też w ngOnChanges zadziałać, gdy zmienna w parencie się zmieni i nie może to być z jakiegoś powodu przeniesione na childa.

1 użytkowników online, w tym zalogowanych: 0, gości: 1