Hello! Perhaps this question is already present here, but after searching I did not find anything. The question is as follows:

There is an editWordForm form, for one of the fields ( descLingv ) a “prompt” is needed - you can enter the text manually or select text from the list of already existing texts. Texts are requested from the database.

There is a button, by clicking on which a modal window opens (the getlastwords (type) function). It displays a list of existing texts with the ability to filter - when you click on the desired text, the value should be recorded in wordDetails.DescLingvText .

However, when the button is pressed, in addition to the prescribed function getlastwords (type) , the saveWord function is called , which is registered in the ng-submit attribute of the form.

How to "cancel" the submit event or exclude a button from the form?

<form class="form-horizontal" role="form" novalidate angular-validator name="editWordForm" ng-submit="saveWord()"> <label class="control-label">Дескриптор</label> <button class="btn btn-default btn-xs" id="lastWords" ng-click="getlastwords(1)"> Выбрать текст </button> <input class="form-control" name="descLingv" type="text" ng-model="wordDetails.DescLingvText"> <div class="col-xs-4"> <input type="submit" value="Сохранить изменения"/> </div> 

    1 answer 1

    Add the type="button" attribute to your button

     <button type="button" class="btn btn-default btn-xs" id="lastWords" ng-click="getlastwords(1)"> 

    By default, the type for the button is set to submit this way when clicked and the form was sent.