I'm making an application where I register for a new company, I'm a beginner in java script and I'm also using Angular in my project. What I want to do is, when the user clicks register, give a success message and then go back to home page, I tried with alert, but I do not know how to make the message appear only after the registration is successful .
This is my form:
<form role="form" name="formCadastroEmpresa" ng-submit="formCadastroEmpresa.$valid && cadastrarEmpresa()" novalidate>
I need to call the message submit="formCadastroEmpresa.$valid && cadastrarEmpresa()"
is true, and before I call the cadastrarEmpresa()
of the angle I need to give an alert, or something like that to warn the user that everything has happened.
An example of a form group I'm using:
<div class="form-group" ng-class="{ 'has-error' : formCadastroEmpresa.empresaTelefone.$touched && formCadastroEmpresa.empresaTelefone.$invalid }">
<label>Telefone</label>
<input
minlength="13"
name="empresaTelefone"
class="form-control"
id="telefone"
placeholder="Telefone fixo"
ng-model="empresa.telefone" required>
</div>
<p ng-show=" formCadastroEmpresa.$submitted && formCadastroEmpresa.empresaTelefone.$invalid" style="color:red">Um telefone para contato é necessário</p>