Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created October 8, 2017 16:48
Embed
What would you like to do?
@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