ngx-back-button
Version:
A library for handling a proper angular back button capability
94 lines (87 loc) • 3.31 kB
TypeScript
import * as i0 from '@angular/core';
import { InjectionToken, Signal, EnvironmentProviders } from '@angular/core';
interface NgxBackButtonServiceConfig {
rootUrl?: string;
fallbackPrefix?: string;
}
declare const NgxBackButtonServiceProvider: InjectionToken<NgxBackButtonServiceConfig>;
declare class NgxBackButtonDirective {
#private;
ngxBackButton?: string;
onClick(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxBackButtonDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<NgxBackButtonDirective, "[ngxBackButton]", never, { "ngxBackButton": { "alias": "ngxBackButton"; "required": false; }; }, {}, never, never, true, never>;
}
declare class NgxBackButtonService {
#private;
private _history;
private _navigatingBack;
private _$nextBackNavigationPath;
readonly $nextBackNavigationPath: Signal<string>;
constructor();
getHistory(): string[];
/**
* @param fallback
* @param config Optional configuration to override the root configuration (typically from child routes)
* @return Boolean: True === Had an history to go back to
*/
back(fallback?: string, config?: NgxBackButtonServiceConfig | null): boolean;
private _getFallBackNavigationPath;
private _resolveRelativeFallbackNavigationPath;
private _updateNextBackNavigationPath;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxBackButtonService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<NgxBackButtonService>;
}
/**
* Provides the NgxBackButton service with the given configuration.
* Use this in your root application providers.
*
* When both root and child configurations are provided, the child configuration
* will override the root configuration for routes under that path, following
* Angular's hierarchical dependency injection.
*
* @param config Configuration for the NgxBackButton service
* @returns Environment providers for NgxBackButton
*
* @example
* ```typescript
* bootstrapApplication(AppComponent, {
* providers: [
* provideNgxBackButton({
* rootUrl: '/home',
* fallbackPrefix: '/tabs'
* })
* ]
* })
* ```
*/
declare function provideNgxBackButton(config?: NgxBackButtonServiceConfig): EnvironmentProviders;
/**
* Provides child-level configuration for NgxBackButton service.
* Use this in lazy-loaded route providers to override the root configuration.
*
* This configuration will override the root configuration for all components
* and directives within the route's component tree, following Angular's
* hierarchical dependency injection.
*
* @param config Configuration for the NgxBackButton service at child level
* @returns Environment providers for NgxBackButton child configuration
*
* @example
* ```typescript
* export const routes: Routes = [
* {
* path: 'child',
* providers: [
* provideNgxBackButtonChild({
* rootUrl: '/login'
* })
* ],
* loadComponent: () => import('./child.component')
* }
* ]
* ```
*/
declare function provideNgxBackButtonChild(config?: NgxBackButtonServiceConfig): EnvironmentProviders;
export { NgxBackButtonDirective, NgxBackButtonService, NgxBackButtonServiceProvider, provideNgxBackButton, provideNgxBackButtonChild };
export type { NgxBackButtonServiceConfig };