{ path: 'news/:slug', component: NewsItemComponent },
使用此导入将其连接到组件
import { NewsItemComponent } from './news-item/news-item.component';
我在Visual Studio中为我的IDE介绍,所以它确实告诉我这条路是否不正确。
到目前为止,一切都很好,但是,如果我导航到/新闻/my-news-intem-slug
,则URL有200个响应,但是在我的Chrome Developer工具网络选项卡中,没有尝试调用API端点,并且没有任何控制台。这不是CORS的事情,我已经测试了Angular之外的API呼叫,但是由于没有对API进行呼叫,这是无关紧要的。从所有这些我都可以假设“ NewsItemComponent”没有被击中。
据我所知,我正在根据我使用的Angular版本正确设置路线!
您启用了SSR,因此在服务器上进行了API调用,并且内容已列为PRERENDER。
内容存储在angular transfer cache
.中。
import { provideClientHydration } from '@angular/platform-browser';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent, {
providers: [
provideClientHydration(withNoHttpTransferCache()),
],
});