我尝试使用"location.go"
单击表行项时更新URL参数值而不刷新页面。不幸的是,我收到类似"Property 'go' does not exist on type 'Location'"
请专家提供建议吗?
实际网址:http://localhost:4200/technicalSettings/disciplines
预期的URL,无需在单击行时刷新页面:http://localhost:4200/technicalSettings/disciplines/1109
版本:Angular 7
import { Location, LocationStrategy, PathLocationStrategy} from "@angular/common";
onRowClicked(event: any) {
this.isRowSelected = true;
this.selectedId = event.id;
this.selectedItem = event;
this.dataService.set(event);
location.go("technicalSettings/disciplines", this.selectedId);
//this.router.navigate(["technicalSettings/disciplines", this.selectedId]);
}
答案 0 :(得分:5)
由于位置服务是角度通用模块的一部分。在组件类中的import语句下面添加
import { Location } from '@angular/common';
否则,它引用窗口/文档的Location属性。