Angular :类型 'go' 上不存在属性 'Location'

标签 angular location

我正在尝试使用 "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/

相关文章:

Angular 和麦克风录音机到 mp3 : Lame is not defined

javascript - 如何在 Angular2 中实现 'category filter'

angular - 获取 "No ' Access-Control-Allow-Origin' header is present on the requested resource"错误,即使 CORS 设置正确

google-maps - 从 Google 位置历史记录下载 KML 数据的当前 URL?

java - 如何在android中每1分钟移动一次获得不同的纬度和经度?

Swift Firebase TableView 与当前用户的距离

javascript - angular-cli 编译错误 + monorepo : error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'

javascript - 如何在到期前知道日期

sql - 雪花中的地理空间连接

android - 使用 Titanium 创建的 Android 应用程序数据存储在 Mac 中的位置