当我给路由器导航数据没有在路由器页面更新时。但是当我刷新浏览器时,更新的数据可以显示在路由器页面。我想只重新加载组件。我尝试路由器导航首先导航到虚拟组件,然后导航到路由器页面。还有其他更好的方法???
import { Component, OnInit } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Appsettings } from '../../../app.settings'
import { Http, Response, Headers } from '@angular/http';
import { Router, Routes, RouterModule } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
import { BaThemeSpinner } from '../../../theme/services';
import { ToastrService,ToastrConfig } from 'toastr-ng2';
@Component({
selector: 'add-service-modal',
styleUrls: [('./cat-modal.component.scss')],
templateUrl: './cat-modal.component.html'
})
export class CatModal implements OnInit {
modalHeader: string;
modalContent: string;
constructor(private activeModal: NgbActiveModal,private http:Http,
private toastrService: ToastrService, private toastrConfig: ToastrConfig,
private router: Router, private spinner: BaThemeSpinner)
{
toastrConfig.timeOut = 0;
}
approveCategory(userId,catId)
{
console.log(userId);
console.log(catId);
this.closeModal();
this.spinner.showBlur();
let params = {
user_id : userId,
cat_id : catId
}
let result=
this.http.post(Appsettings.API__URL+'/adminUser/approveCategory',params
).map((res: Response) => res.json());
console.log(result);
let subresult = result.subscribe((data) =>{
this.spinner.hide();
console.log('sub result');console.log(data);console.log('sub
result');
if(data.status==1)
{
this.toastrService.success('Category approved!',
'Success!');
this.router.navigateByUrl('/DummyComponent',
{skipLocationChange: true}).then(()=>
this.router.navigate(["/pages/manageApproval"]));
}
else
{
this.toastrService.success(data.message, 'Failed!');
}
});
}
denyCategory(userId,catId)
{
console.log(userId);
console.log(catId);
let params = {
user_id : userId,
cat_id : catId
}
this.closeModal();
this.spinner.showBlur();
let result=
this.http.post(Appsettings.API__URL+'/adminUser/denyCategory', params
).map((res: Response) => res.json());
console.log(result);
let subresult = result.subscribe((data) =>{
{
skipLocationChange: true}).then(()=>
this.router.navigate(["/pages/manageApproval"]));
this.spinner.hide();
});
}
ngOnInit() {}
closeModal() {
this.activeModal.close();
}
}