Guest User

Untitled

a guest
Feb 15th, 2018
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. 'ERROR TypeError: Cannot read property 'UserName' of undefined
  2.  
  3. TypeError: _co.user is undefined
  4.  
  5. <input type="text" name="UserName" #UserName ="ngModel" [(ngModel)]="user.UserName">
  6.  
  7. import { Component, OnInit } from '@angular/core';
  8. import { User } from '../shared/user.model';
  9. import { NgForm } from '@angular/forms';
  10. import { UserService } from '../shared/user.service';
  11.  
  12. @Component({
  13. selector: 'app-sign-up',
  14. templateUrl: './sign-up.component.html',
  15. styleUrls: ['./sign-up.component.css']
  16. })
  17. export class SignUpComponent implements OnInit {
  18.  
  19. user : User;
  20.  
  21. constructor( private userService : UserService) { }
  22.  
  23. ngOnInit() {
  24. }
  25.  
  26. OnSubmit(form : NgForm){
  27.  
  28. this.userService.addUser(form.value).subscribe((data : any)=> {
  29.  
  30. if(data.Succeeded ==true){
  31. console.log("transferred successfull");
  32. }
  33. });
  34. }
  35.  
  36. }
  37.  
  38. export class User {
  39.  
  40. UserName: string;
  41. Password: string;
  42. Email: string;
  43. FirstName: string;
  44. LastName: string;
  45.  
  46. }
Add Comment
Please, Sign In to add comment