角度:属性“ go”在类型“ Location”上不存在

问题描述 投票:0回答:1

我正在尝试使用"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]);
  }

我正在尝试使用“ location.go”单击表行项时更新URL参数值,而不刷新页面。不幸的是,我收到类似“属性'go'在类型'...上不存在'...

angular location
1个回答
0
投票

由于定位服务是角度通用模块的一部分。在组件类的下面添加import语句

© www.soinside.com 2019 - 2024. All rights reserved.