typescript - display error message on form if the message is not empty angular 2 -
i have register form , wish display error message on form, in case went wrong.
in .ts file, have following code :-
onsubmit(email, password, name, surname, username, homephonenumber, mobilenumber){ this._userservice.register(email, password, name, surname, username, homephonenumber, mobilenumber) .subscribe((result) => { if (result.success == "true") { //this._userservice.login(email, password); } else { this.errormessage = result.message; } });
}
and in form have following:-
<div class="alert alert-danger" ng-if="{{errormessage}}"></div>
this throwing error in console:-
can't bind 'ng-if' since isn't known property of 'div'
how can error message display?
thanks , time.
ng-if
angularjs syntax. angular 2 change :
<div class="alert alert-danger" *ngif="errormessage"></div>
angular 2 template docs : link
Comments
Post a Comment