Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- userSpecificData:any = {_id:'-',name: '-', email: '-', username: '-', password: '-', phone: '-',education:'-',location:'-',title:'-',company:'-'}
- onEditFormSubmit(){
- const user = {
- _id:this.userSpecificData._id,
- name: this.userSpecificData.name,
- email: this.userSpecificData.email,
- username: this.userSpecificData.username,
- password: this.userSpecificData.password,
- phone:this.userSpecificData.phone,
- location:this.userSpecificData.location,
- title:this.userSpecificData.title,
- company:this.userSpecificData.company,
- education:this.userSpecificData.education
- }
- if (this.EditPageUserForm.dirty && this.EditPageUserForm.valid) {
- this.authService.updateUserData(user).subscribe(data => {
- console.log(data);
- if(data.success){
- this.flashMessage.show('You are now successfully registered, redirecting to Login page..', {cssClass: 'alert-success', timeout: 4000});
- //setTimeout(function(){
- this.navCtrl.push(LoginPage);
- // },4000)
- console.log('sucess');
- } else {
- this.flashMessage.show('Something went wrong', {cssClass: 'alert-danger', timeout: 4000});
- // this.router.navigate(['/register']);
- console.log('faild');
- return false;
- }
- });
- }
- }
- updateUserData(user) {
- let headers = new Headers();
- console.log(headers,user);
- headers.append('Content-Type','application/json');
- return this.http.put('http://localhost:3000/users/user/:id', user,{headers: headers})
- .map(res => res.json());
- }
- router.put('/user/:id', function(req, res){
- User.findByIdAndUpdate({_id: req.params.id},
- {
- name: req.body.name,
- email: req.body.email,
- username: req.body.username,
- phone:req.body.phone,
- location:req.body.location,
- title:req.body.title,
- company:req.body.company,
- education:req.body.education
- }, function(err, docs){
- if(err) res.json(err);
- else
- {
- console.log(docs);
- res.redirect('/user/'+req.params.id);
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement