What is Simplechanges in Angular? Is it an Angular API?

Asked

Viewed 95 times

2

I have the following code:

@Input() listas: IniciarFuncaoModel;

 ngOnChanges(changes: SimpleChanges): void {
    if (changes.listas) {
      this.iniciarFuncao();
    }
  }
  • Simplechanges is an Angular API?
  • I understood that in the example, Simplechanges is typing the changes parameter. (That’s it?)
  • But I don’t understand why you use 'changes.list' as if parameter.
  • My question is: Typing the changes parameter with Simplechanges causes the list variable to become an attribute of the changes parameter?!

1 answer

3


Simplechanges is an Angular API?

Is the interface representing the object of changes for all input properties

I understood that in the example, Simplechanges is typing the changes parameter. (That’s it?)

Yes, this typing the variable changes

But I don’t understand why you use the changes.lista as a parameter of if.

if is a decision structure, a decision is made as to whether there is such a lista It’s like I said in the first answer: lista is a data input element, when it contains data, executes the this.iniciarFuncao();

My question is: When typing the changes parameter with Simplechanges, it causes the variable listas becomes an attribute of the parameter changes?

Yeah, he makes them input of entree be reviewed and allowed to verify your change as already demonstrated by yourself if(changes.lista).


Interface

interface SimpleChanges {
    __index(propName: string): SimpleChange
}

References

Browser other questions tagged

You are not signed in. Login or sign up in order to post.