openJukeboxesModalToGroup

openJukeboxesModalToGroup

在我的控制器中,我有方法


$ scope.openJukeboxesModalToGroup-打开模式弹出窗口
$ scope.searchJukeboxes ---在页面上搜索
$ scope.keyPressed-捕获按键


在偏用表格中

<form class="form-inline" role="form" ng-submit="deadForm()">
    <div class="form-group">
         <button ng-click="openJukeboxesModalToGroup()" class="btn btn-info">Add Stores to Group</button>
    </div>
    <div class="form-group">
        <input type="text" ng-model="jukeboxFilter" ng-keypress="keyPressed($event, 'search')" class="form-control" placeholder="search">
    </div>
    <button type="button" ng-click="searchJukeboxes()" class="btn btn-info"><span class="glyphicon glyphicon-search"></span></button>
    <button type="button" ng-click="resetFilter()" class="btn btn-info"><span class="glyphicon glyphicon-repeat"></span></button>
</form>


keyPressed方法是

$scope.keyPressed = function($event, eventType) {
        $event.stopImmediatePropagation();
        if(eventType=='search') {
            if($event.which==13) {
                $scope.searchJukeboxes();
           }
       }
 };


每当有人在文本栏中键入内容并单击enter时,我都尝试开始搜索。但是我也不知道怎么调用openJukeboxesModalToGroup()方法。我试图通过调用stop event propagagation,更改openJukeboxesModalToGroup()方法的名称来停止此操作。但是没有任何效果。任何帮助。

deadForm()方法是隐含的,我在chrome控制台中没有收到任何错误。

最佳答案

openJukeBoxesModalToGroup()的按钮更改为此:

<button type="button" ng-click="openJukeboxesModalToGroup()" class="btn btn-info">Add Stores to Group</button>


问题是您未提供类型,因此将按钮归类为提交,在这种情况下,将通过enter submit事件触发openJukeboxesModalToGroup()。

当您在表单中单击Enter时,它将触发提交,我建议您通过ng-submit指令将您的方法添加到表单本身,并使按钮成为提交...

<form class="form-inline" role="form" ng-submit="searchJukeboxes()">
    <div class="form-group">
         <button type="button" ng-click="openJukeboxesModalToGroup()" class="btn btn-info">Add Stores to Group</button>
    </div>
    <div class="form-group">
        <input type="text" ng-model="jukeboxFilter" ng-keypress="keyPressed($event, 'search')" class="form-control" placeholder="search">
    </div>
    <button type="submit" ng-click="searchJukeboxes()" class="btn btn-info"><span class="glyphicon glyphicon-search"></span></button>
    <button type="button" ng-click="resetFilter()" class="btn btn-info"><span class="glyphicon glyphicon-repeat"></span></button>
</form>

10-06 06:58