0

structure is

1--login component
  1.1--forget password component
  1.2--reset password component

For that I created the module named "login module"

Here is my coding:

app.routing

 {
path: '',
redirectTo: 'login',
pathMatch: 'full',

 },
 {
   path: 'login',
   component: LoginComponent,

   children: [
    {
      path: 'login',
      canActivate: [AuthServiceGuard],
      loadChildren: './login/login.module#LoginModule'
    }
   ]
 }

login.routing

const routes: Routes = [
 {
  path:'',
  component : LoginComponent,
  data:{
    title:'login'
  },
   children:[{
      path:'forgotPassword',
      component:forgotPwdComponent,
      data:{
        title:'ForgotPassword'
      }
    },
   {
      path:'resetPassword',
      component:ResetPwdComponent,
      data:{
        title:'ResettPassword'
      }
    }]

And in login.html i used routerLink as,

<a class="achortag" routerLink="/forgotPassword">Forgot Password</a>

Now getting error like:


core.js:1673 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'forgotPassword'
Error: Cannot match any routes. URL Segment: 'forgotPassword'

I called forgetpwdComponent and resetpwdcomponent in loginmodule and

I called loginmodule in appmodule Is there any problem in my step which I did.

can anybody guide me??

2 Answers 2

1

currently your forgot password route is /login/login/forgotPassword

you can change your routing something like this

app.routing

[
   {
       path: '',
       redirectTo: 'login',
       pathMatch: 'full',
   },
   {
       path: '',
       canActivate: [AuthServiceGuard],
       loadChildren: './login/login.module#LoginModule'
   }
]

in this case your route is /login/forgotPassword

if you want to have the route /forgotPassword instead of /login/forgotPassword

you can change your code something like below

app.routing

[
  {
     path: '',
     canActivate: [AuthServiceGuard],
     loadChildren: './login/login.module#LoginModule'
   }
]

login.routing

const routes: Routes = [
  {
     path:'login',
     component : LoginComponent,
     data:{
     title:'login'
  },
  {
     path:'forgotPassword',
     component:forgotPwdComponent,
     data:{
        title:'ForgotPassword'
     }
   },
   {
      path:'resetPassword',
      component:ResetPwdComponent,
      data:{
         title:'ResettPassword'
      }
   }
]
Sign up to request clarification or add additional context in comments.

3 Comments

that is not a routing, I am giving the modulename,login is my folder
@AngelReji Sorry I don't understand what you say, please can you clarify?
and I have updated the answer, you should not be import LoginComponent into AppModule if it is a part of LoginModule
0

Try like this:

[routerLink]="['login/forgotPassword']

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.