![](/img/trans.png)
[英]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.