簡體   English   中英

ng-submit不會觸發該事件

[英]ng-submit doesn't fire the event

我一直堅持這種簡單的表單提交方式。 我覺得一切都正確,但這是行不通的。

我的html

<html ng-app = 'myApp'>      
<div ng-controller="Tabs">  
...

       <form ng-submit="sendClicked()" >
          <div class="input-group">
              <input type="text" class="form-control" ng-model="text"/>

             <span class="input-group-btn" >
                 <button class="btn btn-info" type="submit">SEND</button>
             </span>
          </div>
       </form>
  ...
</div>
</html>

我的app.js

myApp.controller('Tabs', function ($scope) {

    $scope.sendClicked = function () {
        console.log('can reach here');
        if($scope.text) {
                socket.emit('send message', $scope.text);
                $scope.text = null;
        }
    };

});

必須是輸入類型Submit ,但是您必須具有按鈕,該按鈕永遠沒有type屬性屬性

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM