javascriptangularjsformsonclicklistenerng-submit

ng-submit doesn't fire the event


I'm stuck with this simple form submission. I feel that everything is right, but it doesn't work.

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

});

Solution

  • Must be input type submit, but you have button, that doesn't ever have type attribute property