/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
adev/src/app/features/not-found/not-found.ts
36 строк
1 KB
Matthieu Riegler
docs(docs-infra): remove explicit OnPush
25 мар 2026, 22:58
25 мар 2026, 22:58
1938054
Код
Авторство
О чём код?
/*! * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Component, inject, signal} from '@angular/core'; import {RelativeLink, Search, SearchItem, SearchResultItem} from '@angular/docs'; import {ActivatedRoute, RouterLink, UrlSegment} from '@angular/router'; @Component({ imports: [SearchItem, RouterLink, RelativeLink], templateUrl: './not-found.html', styleUrl: './not-found.scss', }) export class NotFound { private readonly search = inject(Search); protected readonly searchResults = signal<SearchResultItem[]>([]); constructor() { const activatedRoute = inject(ActivatedRoute); const searchTerms = this.extractSearchTerm(activatedRoute.snapshot.url); if (searchTerms) { // We're using the one-shot query request to not interfere with the main search signal this.search.searchWithQuery(searchTerms).then((results) => { this.searchResults.set(results ?? []); }); } } private extractSearchTerm(url: UrlSegment[]): string { return url.join(' ').replace(/[-_/]/g, ' '); } }