0

Error Message: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'systemAdmin/createCategory'

Update: I found out the error. The App-Routing.module.ts should be systemAdmin/createCategory instead. Spelling error.

App-Routing.module.ts

{ path: 'systemAdmin/createcategory', component: CreateCategoryComponent },

App.module.ts

//...ommitted irrelevant imports
import { CreateCategoryComponent } from './systemAdmin/create-category/create-category.component';

@NgModule({
  declarations: [
    AppComponent,
    IndexComponent,
    HeaderComponent,
    FooterComponent,
    MainMenuComponent,
    SidebarComponent,
    //....others
    CreateCategoryComponent
  ],

createCategory(newCategory: Category) : Observable<any> {

  /*let createCategoryReq = {
    "username": this.sessionService.getUsername(),
    "password": this.sessionService.getPassword(),
    "category": newCategory
  }; */

  //Not too sure where to add newCategory
  return this.httpClient.get<any>(this.baseUrl+"username="+this.sessionService.getUsername()+"&password="+this.sessionService.getPassword()).pipe (
    catchError(this.handleError)
    );
  }
0

1 Answer 1

1

Your Routing Module should look like that:

const routes: Routes = [
  {path: 'systemAdmin/createcategory', component: CreateCategoryComponent},
  {path: '**', component: PageNotFoundComponent}
];

@NgModule({
  imports: [RouterModule.forRoot(routes, {enableTracing: false})],
  exports: [RouterModule]
})
export class AppRoutingModule {
}

With enable Tracing = true there are some log outputs on the console. For further info have a look at: https://angular.io/guide/router

Sign up to request clarification or add additional context in comments.

1 Comment

i found out my error but seems like ur method works as well. So i'm going to mark it as complete to close it. Thank you!

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.