在网址中隐藏ID或标题以获取机密信息

时间:2019-10-28 14:00:18

标签: javascript angular typescript

我需要传递带有URL的ID或标题以将其传递到其他组件,但我不需要在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']">

我该怎么做?

1 个答案:

答案 0 :(得分:1)

在这种情况下,您应该使用一项服务。在这项服务中,您将选择存储在一个主题中,例如从rxjs中获取 BehaviourSubject ,然后在子组件中查询该服务中的选择。

let link = ApolloLink.from([
  onError(({ graphQLErrors, networkError }) => {
    if (graphQLErrors) {
      graphQLErrors.map(({ message, locations, path }) =>
        console.log(
          `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
        )
      );
    }
    if (networkError) console.error(`[Network error]: ${networkError}`, networkError.stack);
  }),
  ApolloLink.split(
    operation => operation.getContext().important === true,
    httpLink, // don't batch important
    batchHttpLink
  ),
]);