Angular 5 - Refresh component (not the whole page)

Right now I have a button: Reset Default

I call the (click)="onResetDefault()"buttons inside the tag, and I want the method to onResetDefault()simply update this particular component and NOT the entire window (as opposed to location.reload()). How should I do it? Responses to using angular 2+ methods would be appreciated :)

+4
source share
1 answer

Create a local variable in your component (suppose using typescript if Angular 2 +):

myValue: string;

Then you control this variable in other ways. And then you call your onResetDefault () method in your component, which looks like this:

onResetDefault(): void {
    myValue = 'Default';
}

, , , .

(.html), , , - , :

my value is: {{ myValue }}
0

Source: https://habr.com/ru/post/1689274/


All Articles