Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created October 8, 2017 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/b5305e390b8f347d0eca693e5a057418 to your computer and use it in GitHub Desktop.
Save NMZivkovic/b5305e390b8f347d0eca693e5a057418 to your computer and use it in GitHub Desktop.
@Component({
selector: 'users',
templateUrl: './users.component.html',
})
export class UserComponent implements OnInit {
newUser: User;
constructor(
private userService: UserService
) { }
ngOnInit() {
this.newUser = User.CreateDefault();
}
insertUser() {
this.userService
.insertNewUser(this.newUser)
.subscribe(
data => {
this.newUser._id = data.id;
this.users.push(this.newUser);
this.newUser = User.CreateDefault();
console.log("Added user.");
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment