Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <span style="color:red">{{usererror.username}} </span>
- ...other items here
- <span style="color:red">{{usererror.password}} </span>
- export class LoginComponent implements OnInit{
- public usererror={
- username:"",
- password:""
- }
- //this function is called after a post request
- onLoginError(error:any){
- let message= JSON.parse( error._body);
- console.log(error._body); //first log
- console.log(message) //second log
- }
- }
- [{"field":"username","message":"Username cannot be blank."},
- {"field":"password","message":"Password cannot be blank."}]
- onLoginError(error:any){
- let message= JSON.parse( error._body);
- let message= JSON.parse( error._body);
- for (var i=0; i<message.length; i++){
- this.usererror.message[i].field = message[i].message; //this fails since the
- //usererror doesnt have (message[i].field) property
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement