I'm still learning angular. I was trying to create an example on stackblitz to ask another question and ran into an issue with routing.
I'm trying to set up routing. I have added the following to app.module.ts:
imports: [ BrowserModule,
FormsModule,
RouterModule,
and then I created app-routing.module.ts:
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { NavComponent } from './components/NavComponent';
import { SearchComponent } from './components/SearchComponent';
import { ViewComponent } from './components/ViewComponent';
const routes: Routes = [
{ path: '', redirectTo: '/nav', pathMatch: 'full' },
{ path: 'nav', component: NavComponent },
{ path: 'search', component: SearchComponent },
{ path: 'view', component: ViewComponent }
];
@NgModule({
imports: [ RouterModule.forRoot(routes) ],
exports: [ RouterModule ]
})
export class AppRoutingModule {}
and then added these imports to app.module.ts:
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
I thought that was all I needed to do, but when I load my app, I get:
ERROR
Error: StaticInjectorError(AppModule)[RouterOutlet -> ChildrenOutletContexts]:
StaticInjectorError(Platform: core)[RouterOutlet -> ChildrenOutletContexts]:
NullInjectorError: No provider for ChildrenOutletContexts!
I googled this error and found: No provider for ChildrenOutletContexts (injectionError) and Error: No provider for ChildrenOutletContexts but I don't find these helpful.
Here is my stackblitz: https://stackblitz.com/edit/angular-j1seie?file=src%2Fapp%2Fapp.module.ts.
No idea where to go next.