P
P
PapaDjo2016-03-30 16:02:22
Angular
PapaDjo, 2016-03-30 16:02:22

How to stop form from submitting on enter in Angular?

I know how to do it, but I'm interested in how to do it beautifully within the framework of angular

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2016-03-30
@R0dger

The question is of course vague, because where will enter be pressed, etc.
I have done this in some projects (for input)
I hope you asked about this ..
and if the form is large, then I have configured saving by CTRL + S or CMD + S

S
Sergey, 2016-03-30
Protko @Fesor

nice - tricky question.... Nicely this problem is solved in Angular2, using observable etc.
And for 1.x, you can use the timeout parameter of the request:

var canceler = $q.defer();
$http.post('/someUrl', {timeout: canceler.promise})
  .then(
    response => successCallback(response),
    reason => failCallback(reason)
);
canceler.resolve();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question