I am currently working on a class setup that includes:
import { ClassAsset } from './class-asset';
export class Class {
ClassId:string;
ClassName:string;
Assets:ClassAsset[];
GetAssetsString():string{
var str:string;
this.Assets.forEach(a=>{str+=a.AssetName;});
return str;
}
Attached is the Angular view code snippet
<tr *ngFor="let cls of classList">
<td>{{cls.className}}</td>
<td>{{cls.GetAssetsString()}}</td>
</tr>
The structure of my Component is as follows:
export class ClassesComponent implements OnInit {
private _client:HttpClient;
public classList:Class[]=[];
constructor(client:HttpClient,private route:Router,private datasource:DataService) {
this._client=client;
}
ngOnInit() {
this.getClasses();
}
getClasses()
{
this.datasource.getClassList().subscribe((resp:Class[])=>{
console.log(resp);
this.classList=resp;}
);
}
}
Unfortunately, I encountered the error message below:
TypeError: _v.context.$implicit.GetAssetsString is not a function
Can someone please assist me in identifying what went wrong? (I am still in the learning process with TypeScript...)