Search code examples
angularjsangular-leaflet-directive

ng-include with ng-click raise submit - how to avoid it?


I have html template:

<div ng-controller="MyController">
  <form novalidate>
    Name: <input type="text" ng-model="user.name" />
    <button ng-click="greet(user)">GREET</button>
  </form>
</div>

And I add it like this:

"<div ng-include src=\"'/views/template.html'\"></div>"

This is function in MyController:

$scope.user = {}
    $scope.greet = function (user) {
        alert('hello ' + user.name)
    }

But when I click on button it makes submit it doesn't call greet function.
I also tried to add type="button" to it but it is the same.
Here is the working solution so I don't know what I am missing.


Solution

  • use type="submit" with the submit button, and input instead of button.