Ng-submit不触发事件

ng-submit doesn't fire the event

本文关键字:事件 Ng-submit      更新时间:2023-09-26

我被这个简单的表单提交卡住了。我觉得一切都是对的,但就是行不通。

My 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>

My 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属性属性