0
votes

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)
    );
  }
1

1 Answers

1
votes

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