How to reset data and view of child input on click of parent's button click?

前端 未结 1 1861
Happy的楠姐
Happy的楠姐 2020-12-22 00:19

In our Angular 4 app, we\'ve a

  • which has a
  • The has &l
1条回答
  •  执笔经年
    2020-12-22 01:11

    To initialize a form with "empty" data, I do something like this:

    initializeProduct(): IProduct {
        // Return an initialized object
        return {
            id: 0,
            productName: null,
            productCode: null,
            tags: [''],
            releaseDate: null,
            price: null,
            description: null,
            starRating: null,
            imageUrl: null
        };
    }
    

    And then bind to the initialized product.

    You can find a complete example here: https://github.com/DeborahK/Angular2-ReactiveForms (specifically the APM folder).

    This code is for my "Angular Reactive Forms" course on Pluralsight if you want to see more details on how it was built: https://app.pluralsight.com/library/courses/angular-2-reactive-forms/table-of-contents

    0 讨论(0)
提交回复
热议问题