Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在url中隐藏机密信息的id或标题_Javascript_Angular_Typescript - Fatal编程技术网

Javascript 在url中隐藏机密信息的id或标题

Javascript 在url中隐藏机密信息的id或标题,javascript,angular,typescript,Javascript,Angular,Typescript,我需要将id或标题与url一起传递,以便将它们传递给其他组件,但我不需要在url中显示id或标题 http://localhost:4200/#/news/comment/44/list 我需要我的网址像这样,但它有我的信息 http://localhost:4200/#/news/comment/list 这是我的routerLink: <a mat-icon-button [matTooltip]="'TOOLTIP.LIKE' | translate"

我需要将id或标题与url一起传递,以便将它们传递给其他组件,但我不需要在url中显示id或标题

http://localhost:4200/#/news/comment/44/list
我需要我的网址像这样,但它有我的信息

http://localhost:4200/#/news/comment/list
这是我的routerLink:

<a mat-icon-button [matTooltip]="'TOOLTIP.LIKE' | translate"
                        [routerLink]="['/news/comment/like',row.id,'list']">


我该如何做这项工作?

在您的情况下,您应该使用服务。在该服务中,您将选择存储在主题中,例如rxjs中的行为主题,然后在子组件中查询该服务中的选择

@Injectable()
export class MyService {
  private mySubject: BehaviourSubject<number> = new BehaviourSubject<number>(null);
  myObservable$: Observable<number> = this.mySubject.asObservable();  // <-- use this observable for getting the value

  setValue(id: number) {
    this.mySubject.next(id);
  }
}
@Injectable()
导出类MyService{
private mySubject:BehaviorSubject=新的BehaviorSubject(空);
myObservable$:Observable=this.mySubject.asObservable()//