首页 > 解决方案 > Issue while updating the path param in angular 8 at production build

问题描述

I am working on the angular 8 app, implemented the routing. in the app one of the component is used to show the list of products(like list of mails) and and another component is used to show the details (like gmail) based on the selection, while selecting the product form a list, I am updating the URL path parameter (changing the product id) so user can save the URL for later use.

here is the routing config.

{
path: 'product/:id',
runGuardsAndResolvers: () => false,
pathMatch:'full',
children: [
  { 
    path: '',
    runGuardsAndResolvers:() => false,
    pathMatch:'full',
    component: ProductDetailComponent,
    outlet: 'renderView'
  }]
 },

and for first navigation I am using the simple anchor tag

<a class="dropdown-item "  [routerLink]="['/product',selectedEntityId]" routerLinkActive="active"
              [routerLinkActiveOptions]="{ exact: true }">Products</a>

from product listing component, I am using the following tag

<a href="javascript:void(0)" style="cursor: pointer;" (click)="OnSelect(product)"  [routerLink]="['../',product.product_id]" *ngFor="let entity of prodcutResults" class="list-group-item list-group-item-action"> {{product.name}}</a>     

in the development build its working perfectly fine, but when I try to generate the production build compilation failed due to this expresssion

runGuardsAndResolvers: () => false,

I tried to use other options from Resolver (always|pathParamChange...) but using these configuration parameter does not change

I tried to change this expression into exported function as well

export function predicate(): RunGuardsAndResolvers { 

  return (from: ActivatedRouteSnapshot, to: ActivatedRouteSnapshot)=>false;
 }

but it is not working, anyone having idea about this issue or any alternative approach or suggestion

标签: javascriptangularangular-ui-routerangular-routingangular8

解决方案


推荐阅读