简体   繁体   中英

Property does not exist on type object in angular

I have an object while running i am getting the following error as Property doesn't exist on type object can anyone tell me what am i doing wrong in it.

let filter = {
      project: 'Test',
      flow: 'basic',
      start: 0,
      length: 3
    };

Error:

    src/app/_services/flow.service.ts(14,39): error TS2339: Property 'project' does not exist on type 'object'.
src/app/_services/flow.service.ts(14,62): error TS2339: Property 'flow' does not exist on type 'object'.
src/app/_services/flow.service.ts(14,83): error TS2339: Property 'start' does not exist on type 'object'.
src/app/_services/flow.service.ts(14,106): error TS2339: Property 'length' does not exist on type 'object'.

You probably have filter typed as object[] as well. And property project does not exist on object. If you don't care about typing, you can declare filter as Array<any>:

let filter: Array<any>;

这样做,问题就消失了,

private filter: any[];

The problem may be with your flow.service.ts field where you have set that to type object and all the field in filter don't exist on the type object . In your flow.service.ts change the feild type to any.

filter: any;

使用名称过滤器初始化对象,例如:

filter = [];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM