我不知道为什么这个路由器链接不工作
我只是想让这个路由器导航到搜索模块。好有趣的一点是,页面url是localhost 4200/technology,但仍然停留在主页上,好像没有搜索组件。我真的不知道该怎么办
``` homepage router ```
<a class="link-header" routerLink="search">See Recipe</a>
my app module file
import { RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { MealsComponent } from './meals/meals.component';
import { HttpClientModule } from '@angular/common/http';
import { SearchMealComponent } from './search-meal/search-meal.component';
import { MealAppComponent } from './meal-app/meal-app.component';
import { HomeComponent } from './home/home.component';
import { ReactiveFormsModule } from '@angular/forms';
@NgModule({
declarations: [
AppComponent,
MealsComponent,
SearchMealComponent,
MealAppComponent,
HomeComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
ReactiveFormsModule
],
providers: [RouterModule],
bootstrap: [AppComponent]
})
export class AppModule { }
``` app-routing-module paths ```
const routes: Routes = [
{ path:'search', component:SearchMealComponent }
];
1条答案
按热度按时间u5i3ibmn1#
问题似乎是
app-routing.modules.ts
文件配置不正确homepage router
my app module file
app-routing-module paths
这些问题通常发生在您创建新文件时不使用
ng generate
的情况下,您将面临排除资产或依赖项的风险。希望能有所帮助。