title: Getting Uncaught (in promise): RangeError: Maximum call stack size exceeded in angular 4 when enter wrong URL
body: <p>I want to redirect user to <strong>page not found</strong> page when user enter workng</p>
  
  <p>This is my <strong>app-routing.module.ts</strong></p>
  
  <pre><code>const routes: Routes = [
          {path:'products',loadChildren:'app/core/component/frontend/productdetail/productdetail.module#ProductDetailFrontModule'},
          {path:'product-types',loadChildren:'app/core/component/frontend/productdetail/catesubcate.module#CateSubcateComponentModule'},
          {path: '**', loadChildren: 'app/core/component/frontend/pagenotfound/pagenotfound.module#PageNotFoundModule' }
         ]
  </code></pre>
  
  <p><strong>productdetail.module.ts</strong></p>
  
  <pre><code>const route:Routes =[
  {
      path:':slug',
      component:ProductDetailFrontComponent
  },{ 
      path: '**', 
      component: PageNotFoundComponent 
  }]
  </code></pre>
  
  <p>and <strong>catesubcate.module.ts</strong></p>
  
  <pre><code>const route:Routes =[
  {
      path:':slug',
      component:CateSubcateComponent
  },{
      path:':cate/packages/:slug',
      component:CateSubcateComponent
  },{ 
      path: '**', 
      component: PageNotFoundComponent 
  }] 
  </code></pre>
  
  <p>when I enter URL like <code>http://localhost:4200/products/2-panel-cd-folder</code>
  everything works fine but when I add junk data like <code>http://localhost:4200/products123/2-panel-cd-folder</code> i get <strong>Uncaught (in promise): RangeError: Maximum call stack size exceeded</strong> error.</p>
  
  <p>same thing happen when with URl <code>http://localhost:4200/product-types/cd/packages/cd-jewel-case</code>.</p>
  
  <p>when I enter <code>http://localhost:4200/product-types123/cd/packages/cd-jewel-case</code> it give me error, but <code>http://localhost:4200/product-types/cd/packages123/cd-jewel-case</code> show me <strong>page not found</strong> page.</p>
  
  <p>when I enter <code>http://localhost:4200/templates123</code> instead of <code>http://localhost:4200/templates</code> this also show <strong>page not found</strong> page</p>
  
  <p>I've change my code according to this <code>https://stackoverflow.com/questions/40132255</code> but not helping.</p>
  
  <p>I've search so many thing on net but nothing is working. Can someone help me?</p>