I attempted to utilize a method from the model class, but encountered an error:
ERROR TypeError: act.sayHi is not a function
Below is my code snippet:
Model Class myModelClass.ts
export interface IMymodel {
name: string;
address: string;
age: number;
}
export class Mymodel implements IMymodel {
name: string;
address: string;
age: number
constructor() {}
sayHi(name): string {
console.log('Hiii' + name);
return 'Hiii'+name;
}
}
Component MyComponent.ts
import { IMymodel, Mymodel } from '../model/myModelClass.ts';
@Component({
selector: 'my-component',
templateUrl: 'myComponent.html'
})
export class MyComponent {
...
prepareData(data: Array<IMymodel>): Array<IMymodel> {
data.map((act: Mymodel) => {
act.sayHi(act.name);
});
return data;
}
}