Angular2无法从Observable对象访问子数组Object

时间:2017-11-19 02:51:07

标签: angular nested

我的对象层次结构如下所示

export interface MandatoryTags {
    key: string;
    values: string[];
}

export interface Template {
    templateName: string;
    mTags: MandatoryTags[];

}

我试图从子接口访问数组。我收到错误Property' mTags'类型'模板'

上不存在
this.templateService.getTemplate(value).subscribe(res=>{

          this.selectedTemplate = res as Template;

            console.log(JSON.stringify(this.selectedTemplate)); //Works
            console.log(this.selectedTemplate.templateName);    //Works
    //      this.listOptions =  this.selectedTemplate.mTags; --> getting error :Property 'mTags' does not exist on type 'Template'

      }, err=>{
          console.log(err);
      });

0 个答案:

没有答案