Angular 5 - “Cannot read property of undefined”

后端 未结 5 971
终归单人心
终归单人心 2021-01-04 07:12

In Angular 5, for input



        
5条回答
  •  迷失自我
    2021-01-04 07:48

    techSpecMeta: {};
    

    In Type script this means to declare a property of type {} with no value initialized. It is the same as:

    techSpecMeta: Object;
    

    You should instead be doing

    techSpecMeta = {};
    

    To make the binding work, you will need the property make as well.

    techSpecMeta = {make: null};
    

    Ideally you would create a class/interface for TechSpecMeta

    class TechSpecMeta {
        make: null;
        anotherProperty: null;
    }
    

    and use it in your component

    techSpecMeta = new TechSpecMeta();
    

提交回复
热议问题