how to stop ngOnChanges Called before ngOnInit()

后端 未结 3 1778
南方客
南方客 2020-12-13 14:07

In my angular application, i came up with a situation where ngOnchanges should only be called when the inputs are bound to changes. so, is there a way to stop the execution

3条回答
  •  时光说笑
    2020-12-13 14:30

    In case it helps anyone here's an example of how I implemented the isFirstChange() solution suggested by @n00dl3 into my AngularJS app:

    this.$onChanges = (changes) => {
        if (!changes.value.isFirstChange()) {
            // do stuff
        }
    };
    

提交回复
热议问题