路由元数据
通过 RouteMeta
类型可以为生成的路由配置添加额外的路由元数据。通过路由元数据可以定义页面标题,所需的 guards, resolvers, providers 以及其他选项。
定义路由元数据
import { Component } from '@angular/core';
import { RouteMeta } from '@analogjs/router';
import { AboutService } from './about.service';
export const routeMeta: RouteMeta = {
title: 'About Analog',
canActivate: [() => true],
providers: [AboutService],
};
@Component({
standalone: true,
template: `
<h2>Hello Analog</h2>
Analog is a meta-framework on top of Angular.
`,
})
export default class AboutPageComponent {
private readonly service = inject(AboutService);
}