Skip to content

Commit a554cdc

Browse files
author
Raphael Balet
committed
init - repo
1 parent 2e978b1 commit a554cdc

23 files changed

+12747
-2
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
14+
[*.md]
15+
max_line_length = off
16+
trim_trailing_whitespace = false

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# IDEs and editors
15+
.idea/
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# Visual Studio Code
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
.history/*
30+
31+
# Miscellaneous
32+
/.angular/cache
33+
.sass-cache/
34+
/connect.lock
35+
/coverage
36+
/libpeerconnection.log
37+
testem.log
38+
/typings
39+
40+
# System files
41+
.DS_Store
42+
Thumbs.db

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 100,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"semi": false,
6+
"arrowParens": "always"
7+
}

.vscode/extensions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3+
"recommendations": ["angular.ng-template"]
4+
}

.vscode/launch.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3+
"version": "0.2.0",
4+
"configurations": [
5+
{
6+
"name": "ng serve",
7+
"type": "pwa-chrome",
8+
"request": "launch",
9+
"preLaunchTask": "npm: start",
10+
"url": "http://localhost:4200/"
11+
},
12+
{
13+
"name": "ng test",
14+
"type": "chrome",
15+
"request": "launch",
16+
"preLaunchTask": "npm: test",
17+
"url": "http://localhost:9876/debug.html"
18+
}
19+
]
20+
}

.vscode/tasks.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3+
"version": "2.0.0",
4+
"tasks": [
5+
{
6+
"type": "npm",
7+
"script": "start",
8+
"isBackground": true,
9+
"problemMatcher": {
10+
"owner": "typescript",
11+
"pattern": "$tsc",
12+
"background": {
13+
"activeOnStart": true,
14+
"beginsPattern": {
15+
"regexp": "(.*?)"
16+
},
17+
"endsPattern": {
18+
"regexp": "bundle generation complete"
19+
}
20+
}
21+
}
22+
},
23+
{
24+
"type": "npm",
25+
"script": "test",
26+
"isBackground": true,
27+
"problemMatcher": {
28+
"owner": "typescript",
29+
"pattern": "$tsc",
30+
"background": {
31+
"activeOnStart": true,
32+
"beginsPattern": {
33+
"regexp": "(.*?)"
34+
},
35+
"endsPattern": {
36+
"regexp": "bundle generation complete"
37+
}
38+
}
39+
}
40+
}
41+
]
42+
}

README.md

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,89 @@
1-
# ngx-back-button
2-
Angular back button
1+
# @ngx-translate/multi-http-loader [![npm version](https://img.shields.io/npm/v/ngx-back-button.svg)](https://www.npmjs.com/package/ngx-back-button)
2+
3+
A library for handling a proper angular back button capability
4+
5+
* [Installation](#installation)
6+
* [Usage](#usage)
7+
8+
## Installation
9+
10+
```sh
11+
npm install ngx-back-button
12+
```
13+
14+
Inside your `app.module.ts` file.
15+
```typescript
16+
import { NgxBackButtonModule, NgxBackButtonService } from 'ngx-back-button'
17+
18+
imports: [
19+
NgxBackButtonModule.forRoot(), // Default rootUrl === '/'
20+
21+
// Or
22+
NgxBackButtonModule.forRoot({
23+
rootUrl: '/custom', // Or any custom root url
24+
}),
25+
],
26+
providers: [
27+
{
28+
provide: APP_INITIALIZER,
29+
useFactory: () => () => null,
30+
deps: [NgxBackButtonService],
31+
multi: true,
32+
},
33+
]
34+
```
35+
36+
## Usage
37+
Wherever you plan to use the back button logic
38+
39+
```typescript
40+
import { NgxBackButtonModule } from 'ngx-back-button'
41+
42+
imports: [
43+
NgxBackButtonModule,
44+
]
45+
```
46+
47+
Then you can use it in two different way
48+
49+
### Directive
50+
Normal use
51+
```html
52+
<button ngxBackButton>
53+
Back to login
54+
</button>
55+
```
56+
57+
With Fallback
58+
```html
59+
<button ngxBackButton="/login">
60+
Back to login
61+
</button>
62+
```
63+
64+
### Service
65+
```typescript
66+
// foo.component.ts
67+
import { NgxBackButtonService } from 'ngx-back-button'
68+
69+
// ...
70+
constructor(public ngxBackButtonService: NgxBackButtonService) {}
71+
```
72+
73+
Normal use
74+
```html
75+
<button (click)="ngxBackButtonService.back()">
76+
Back to login
77+
</button>
78+
```
79+
80+
With Fallback
81+
```html
82+
<button (click)="ngxBackButtonService.back('/login')">
83+
Back to login
84+
</button>
85+
```
86+
87+
## Authors and acknowledgment
88+
* maintainer [Raphaël Balet](https://github.com/rbalet)
89+
* Inspired by [Nils Mehlhirn](https://nils-mehlhorn.de/posts/angular-navigate-back-previous-page/)

angular.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"ngx-back-button": {
7+
"projectType": "library",
8+
"root": "projects",
9+
"sourceRoot": "projects/src",
10+
"prefix": "lib",
11+
"architect": {
12+
"build": {
13+
"builder": "@angular-devkit/build-angular:ng-packagr",
14+
"options": {
15+
"project": "projects/ng-package.json"
16+
},
17+
"configurations": {
18+
"production": {
19+
"tsConfig": "projects/tsconfig.lib.prod.json"
20+
},
21+
"development": {
22+
"tsConfig": "projects/tsconfig.lib.json"
23+
}
24+
},
25+
"defaultConfiguration": "production"
26+
},
27+
"test": {
28+
"builder": "@angular-devkit/build-angular:karma",
29+
"options": {
30+
"tsConfig": "projects/tsconfig.spec.json",
31+
"polyfills": [
32+
"zone.js",
33+
"zone.js/testing"
34+
]
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)