[英]How to Call function from Component.ts file in service.ts file which is in the same component in angular
[英]How to call a function in one angular component from another component(different .ts file)
文件1.ts
export class1(){
dummy(a,b){
....
}
}
文件2.ts
export class2(){
a: string = "scjhb"
b: string ="mn hbh"
//From here,I want to call dummy pass these parameters and call dummy function from file1.ts.How to do?
dummy(a,b); //I want to call dummmy(a,b)
}
i tried the below thing in File2.ts,but it's not working.
@ViewChild(class1, { static: false }) Classvar: class1; this.Classvar.dummy(a,b)
您可以简单地扩展另一个类[继承]。
提供 Stackblitz 示例: 示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.