从onClick on differents组件调用相同的方法

时间:2017-12-06 19:12:21

标签: angular ionic2

在我的class DiscountCalc: def get_item_price(self): return input('Input a starting price (0 to quit): ') def discount(self, current_price, days): yield (current_price - (current_price*10)//100) def run(self): initial = self.get_item_price() for price in self.discount(initial, 10): print "Price is discounted to : " + str(price) DiscountCalc().run() 上,我有一个导航抽屉(app.html),其中有一个按钮,其中包含:

ion-nav

我已尝试将<button ion-button block clear (click)="showAlert()">Alert</button> 方法设置为showAlert(),但它并未显示app.component.ts alert

还有另一种方法可以做到这一点,而不是在每个组件上创建相同的功能吗?

实施例

console.log("")

我有app.html,我有ion-nav这样:

Button

问题是,我的应用的每个页面都有<button ion-button block clear (click)="showAlert()">Alert</button> ,所以我想检测所有网页上ion-nav的点击次数。

0 个答案:

没有答案