我正在尝试使用 "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]);
}
最佳答案
由于位置服务是 Angular 公共(public)模块的一部分。在您的组件类中添加以下导入语句
import { Location } from '@angular/common';
否则它指的是窗口/文档位置属性。
关于 Angular :类型 'go' 上不存在属性 'Location',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56424006/