通过名为$范围的方法,NG-点击:通过IE执行两次 [英] $scope's method called via ng-click: executed twice by IE

查看:148
本文介绍了通过名为$范围的方法,NG-点击:通过IE执行两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的控制器:

$scope.homeAction = function() {
  console.log("HomeAction");
};

在我看来:

<button ng-click="homeAction()">call homeAction()</button>

在单击按钮时,Chrome和Firefox按预期的方式方法被执行,但执行IE两次。任何想法,为什么?

When clicking the button, the method gets executed as expected by Chrome and Firefox, but IE executes it twice. Any idea why?

下面是重现这一问题的plunker: http://plnkr.co/edit/pedZKjIVGDAYfMl0ZphJ

Here is a plunker that reproduces the issue: http://plnkr.co/edit/pedZKjIVGDAYfMl0ZphJ.

推荐答案

只需添加键入=按钮来的按钮,它应该是固定的。默认的行为是提交,显然与您code弄乱。

Just add type="button"to your button and it should be fixed. Default behaviour is submit and apparently that messes with your code.

<ion-view title="Home">

  <ion-content padding="true">
    <button type="button" ng-click="homeAction()" class="button button-block button-positive">call homeAction()</button>
  </ion-content>

</ion-view>

这篇关于通过名为$范围的方法,NG-点击:通过IE执行两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆