【发布时间】:2019-03-29 21:08:01
【问题描述】:
在我的组件类(HeaderComponent)中, 每次单击changeBannerArrow()和changeBannerImg()这两个函数时,我都想访问changeBtnColorBg函数
这些函数是在 HTML 端的 onclick 事件上触发的
export class HeaderComponent implements OnInit {
imgTotal = 3;
currentImg = 0;
imgHdr = [];
changeBannerImg(imgSelect){
/* some code here */
changeBtnColorBg(this.currentImg, imgSelect);
}
changeBannerArrow(imgSelect){
from = this.currentImg;
/* some code here*/
to = this.currentImg;
changeBtnColorBg(from, to);
}
changeBtnColorBg(from, to){
this.imgHdr[from].selected = false; //change back to transparent
this.imgHdr[to].selected = true; //change bg color
}
}
但是这个结构会产生错误
HeaderComponent.html:15 错误 ReferenceError: changeBtnColorBg 不是 定义
有人可以帮忙吗?我是新手
【问题讨论】:
-
哇,Angular 7 不需要 TypeScript?
标签: javascript angular angular7