Angular material 标识符';类别名称';没有定义';数组';不包含这样的成员 {{rows?rows?.categoryName:'}}的配置文件详细信息 类别名称 类别说明

Angular material 标识符';类别名称';没有定义';数组';不包含这样的成员 {{rows?rows?.categoryName:'}}的配置文件详细信息 类别名称 类别说明,angular-material,angular5,Angular Material,Angular5,这是component.html <div class="example-container"> <div class="pb-16" fxLayout="row" fxLayoutAlign="start center"> <div class="h2 secondary-text"> <b> <u>Profile Details of {{rows ? rows?.catego

这是component.html

<div class="example-container">
   <div class="pb-16" fxLayout="row" fxLayoutAlign="start center">
      <div class="h2 secondary-text">
        <b>
           <u>Profile Details of {{rows ? rows?.categoryName : ''}}</u>
        </b>
       </div>
    </div>
    <br />
    <mat-form-field>
    <mat-label>Category Name</mat-label>
     <input matInput placeholder="category name" value="{{rows ? rows?.categoryName : ''}}">

    </mat-form-field>
         <br />
         <br />
     <mat-form-field class="example-full-width">
       <mat-label>Category Description</mat-label>
       <textarea matInput placeholder="category description" value="{{rows ? rows?.categoryDesc : ''}}"></textarea>

     </mat-form-field>

</div>
import{Component,OnInit,Input}来自“@angular/core”;
从“@angular/material”导入{matsnakbar};
从“@angular/cdk/concurvation”导入{concurveboleanproperty};
从“@angular/common/http”导入{HttpClient};
从“@angular/router”导入{ActivatedRoute}”;
从导入{FormBuilder,FormGroup,Validators,FormControl}
“@angular/forms”;
从“@angular/common”导入{Location};
导入'rxjs/add/operator/debounceTime';
导入“rxjs/add/operator/delay”;
导入'rxjs/add/operator/map';
从“../../../../../fuse-fake-db/service”导入{ServiceContactsFakeDb}
联系人';
从“../../../../../fuse fake db/hero”导入{Data};
从“../../../../../fuse-fake-db/mock-heromes”导入{LIST};
从“./category.service”导入{CategoryService};
@组成部分({
选择器:“配置文件详细信息”,
templateUrl:'./profile.component.html',
样式URL:['./component.scss'],
提供者:[类别服务]
})
导出类ProfileComponent实现OnInit{
构造函数(私有位置:location,私有http:HttpClient,私有
服务:类别服务,专用_Activatedroute:Activatedroute){
}
名称=新FormControl(“”,[Validators.required]);
name1=新表单控件(“”,[需要验证程序]);
最喜欢的季节:任何;
_卡=假;
配置文件=列表;
@输入()类别;
selectedProfile:数据;
原始数据:任何[];
行:任何[];
可重定额=真;
类别名称:任何[];
categoryDesc:any={};
数据=[];
项目:字符串[];
id:字符串;
catName:字符串;
catDesc:字符串;
//selectedProfile:ServiceContactsFakeDb;
setDataLayoutType(值:布尔值){
此._卡=强制执行一个属性(值);
}
恩戈尼尼特(){
//这是getDetail();
this.id=this._Activatedroute.snapshot.params['id'];
console.log(this.id);
this.service.getcategory().subscribe(res=>{
this.rawdata=res;
对于(var i=0;i
我将行定义为数组,将其替换为
rows:any={},而不是rows:any[];


错误表明
是一个数组,但您似乎希望对象包含
categoryName
属性。谢谢,我找到了解决方案
import { Component,OnInit,Input } from "@angular/core";
import { MatSnackBar } from '@angular/material';
import { coerceBooleanProperty } from "@angular/cdk/coercion";
import { HttpClient } from "@angular/common/http";
import { ActivatedRoute } from "@angular/router";
import { FormBuilder, FormGroup, Validators,FormControl } from 
'@angular/forms';
import { Location} from '@angular/common';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/delay';
import 'rxjs/add/operator/map';
import {ServiceContactsFakeDb} from '../../../../../fuse-fake-db/service- 
contacts';
import { Data } from '../../../../../fuse-fake-db/hero';
import { LIST } from '../../../../../fuse-fake-db/mock-heroes';
import {CategoryService} from "../category.service";


@Component({
   selector: 'profile-detail',
   templateUrl: './profile.component.html',  
   styleUrls:['./component.scss'],
   providers:[CategoryService]  
})
export class ProfileComponent implements OnInit {
constructor (private location:Location,private http: HttpClient,private 
service:CategoryService,private _Activatedroute:ActivatedRoute){

}
name = new FormControl('', [Validators.required]);
name1 = new FormControl('', [Validators.required]);
favoriteSeason: any;
_card = false;
profiles = LIST;
@Input() category;

 selectedProfile: Data;

  rawdata:any[];
  rows: any[];
  reorderable = true;
  categoryName : any[];
categoryDesc : any = {};
data = [];
item:string[];
id:string;
catName: string;
catDesc: string;
//selectedProfile: ServiceContactsFakeDb;


setDataLayoutType(value: boolean) {
    this._card = coerceBooleanProperty(value);
}
ngOnInit(){
  // this.getDetail();

  this.id=this._Activatedroute.snapshot.params['id'];
  console.log(this.id);

  this.service.getcategory().subscribe(res => {
    this.rawdata = res;
    for(var i=0;i<this.rawdata.length;i++){
        if(this.id == this.rawdata[i].id){
            this.rows=this.rawdata[i];
            console.log(this.rows);
        }
    }
});

 }