Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

ngonchanges with an array

Anna Helena Drumond answered on March 15, 2023 Popularity 3/10 Helpfulness 1/10

Contents


More Related Answers

  • switch element array angular

  • ngonchanges with an array

    0

    Trigger ngOnChanges for Array or Object

    The solution turned out to be pretty simple, copy the contents into a new array or object with the javascript spread operator (...). This creates a new reference which triggers Angular change detection to call ngOnChanges().

    Here's how to copy an Angular property of type array or object with the spread operator:

    // copy array prop to trigger change detection

    this.myArr = [...this.myArr];

    // copy object prop to trigger change detection

    this.myObj = {...this.myObj};

    Popularity 3/10 Helpfulness 1/10 Language javascript
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Mar 15 2023
    Anna Helena Drumond
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.