ng-submit不会触发事件

时间:2015-07-31 21:24:16

标签: javascript angularjs forms onclicklistener ng-submit

我坚持使用这个简单的表单提交。我觉得一切都是对的,但它不起作用。有什么帮助吗?

我的 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;
        }
    };

});

1 个答案:

答案 0 :(得分:0)

必须输入类型提交,但您有按钮,它没有类型属性属性

相关问题