Javascript ng在表单内单击';t火灾事件

Javascript ng在表单内单击';t火灾事件,javascript,angularjs,ionic-framework,Javascript,Angularjs,Ionic Framework,我只是写了一个简单的按钮,打开一个模态。在这个模式中,我放置了一个“Close”按钮,该按钮触发一个运行良好的“closeLogin()”函数。就像我在登录表单中创建一个啤酒按钮来启动“doTestme()”函数一样,但它从未启动过。请参阅下文: 正确触发模式的按钮: <script id="templates/home.html" type="text/ng-template"> <ion-view view-title="Welcome"> <ion

我只是写了一个简单的按钮,打开一个模态。在这个模式中,我放置了一个“Close”按钮,该按钮触发一个运行良好的“closeLogin()”函数。就像我在登录表单中创建一个啤酒按钮来启动“doTestme()”函数一样,但它从未启动过。请参阅下文:

正确触发模式的按钮:

<script id="templates/home.html" type="text/ng-template">
  <ion-view view-title="Welcome">
    <ion-content class="padding">
      <button type="button" class="button" ng-click="login()">Log-in Test, click on the beer!</button>
    </ion-content>
  </ion-view>
</script>
  .controller('MainCtrl', function($scope, $ionicSideMenuDelegate, $ionicModal, $timeout) {
  $scope.loginData = {};

  // Create the login modal that we will use later
  $ionicModal.fromTemplateUrl('templates/login.html', {
    scope: $scope
  }).then(function(modal) {
    $scope.modal = modal;
  });

  // Triggered in the login modal to close it
  $scope.closeLogin = function() {
    $scope.modal.hide();
  };

  // Open the login modal
  $scope.login = function() {
    $scope.modal.show();
  };

  $scope.doTestme = function() {
    alert("test ok");
  };
<script id="templates/login.html" type="text/ng-template">
<ion-modal-view>
  <ion-header-bar>
    <h1 class="title">Login</h1>
    <div class="buttons">
      <button class="button button-clear" ng-click="closeLogin()">Close</button>
    </div>
  </ion-header-bar>
  <ion-content>
    <form ng-submit="doLogin()">
      <div class="list">
    <label class="item item-input">
      <span class="input-label">Username</span>
      <input type="text" ng-model="loginData.username">
    </label>
    <label class="item item-input">
      <span class="input-label">Password</span>
      <input type="password" ng-model="loginData.password" style="-webkit-flex: 1 0 100px;"><button type="button" ng-click="doTestme()" class="button button-icon ion-beer" style="font-size:35px;"></button>
    </label>
    <label class="item">
      <button class="button button-block button-positive" type="submit">Log in</button>
    </label>
  </div>
</form>
  </ion-content>
</ion-modal-view>
</script>
正确弹出的模式:

<script id="templates/home.html" type="text/ng-template">
  <ion-view view-title="Welcome">
    <ion-content class="padding">
      <button type="button" class="button" ng-click="login()">Log-in Test, click on the beer!</button>
    </ion-content>
  </ion-view>
</script>
  .controller('MainCtrl', function($scope, $ionicSideMenuDelegate, $ionicModal, $timeout) {
  $scope.loginData = {};

  // Create the login modal that we will use later
  $ionicModal.fromTemplateUrl('templates/login.html', {
    scope: $scope
  }).then(function(modal) {
    $scope.modal = modal;
  });

  // Triggered in the login modal to close it
  $scope.closeLogin = function() {
    $scope.modal.hide();
  };

  // Open the login modal
  $scope.login = function() {
    $scope.modal.show();
  };

  $scope.doTestme = function() {
    alert("test ok");
  };
<script id="templates/login.html" type="text/ng-template">
<ion-modal-view>
  <ion-header-bar>
    <h1 class="title">Login</h1>
    <div class="buttons">
      <button class="button button-clear" ng-click="closeLogin()">Close</button>
    </div>
  </ion-header-bar>
  <ion-content>
    <form ng-submit="doLogin()">
      <div class="list">
    <label class="item item-input">
      <span class="input-label">Username</span>
      <input type="text" ng-model="loginData.username">
    </label>
    <label class="item item-input">
      <span class="input-label">Password</span>
      <input type="password" ng-model="loginData.password" style="-webkit-flex: 1 0 100px;"><button type="button" ng-click="doTestme()" class="button button-icon ion-beer" style="font-size:35px;"></button>
    </label>
    <label class="item">
      <button class="button button-block button-positive" type="submit">Log in</button>
    </label>
  </div>
</form>
  </ion-content>
</ion-modal-view>
</script>

登录
接近
用户名
密码
登录
这就好像ng点击从未被监视过一样,我在控制台中没有任何错误,无法调试它,所以。。。有什么想法吗


这是代码笔:

在第一个瞬间,我尝试了两件事:

  • 将函数更改为“doAlert()”
  • 将按钮更改为正常链接“测试”
  • 成功了!但在链接不再触发后几分钟,警报框就关闭了


    我刚在科德普兰试过。请在外面做并发送反馈。

    您不应该使用标签内的按钮。它将无法正常工作。 只需将容器从
    更改为

    
    密码
    

    检查此工作

    很有趣,为什么
    ng点击
    标签
    标签内不工作?谢谢!事实上,您的解决方案解决了我的问题,搜索一个解释,我发现标签链接到表单输入,而div链接到currentcontroler()。非常感谢。这救了我一天:-)谢谢!我不敢相信解决方案会这么简单。不仅仅是按钮。标签内部的任何
    ng点击
    都可能无法正常工作。我在
    按钮内有一个
    ng点击
    ,在
    锚定
    标签内有另一个
    锚定
    标签,两个标签都用
    包装。一旦更改为
    div
    ,单击事件就会生效。