NgxUrl is an Angular library for dealing with url in a more convenient way. It allows easy access to particular parts of the url. It also provides tracking of url changes, so that it is easy to compare current and previous urls.
NPM:
npm install ngx-urlYarn:
yarn add ngx-urlUse Url as any other service:
import {Url} from 'ngx-url';
class Component {
constructor(private url: Url) { }
}With Url service you are able to:
- create a url state containing handy properties
const urlState = this.url.createState('some/url/');- subscribe to url changes that are updated on every navigation
this.url.changes$.subscribe(({current, previous}: UrlChanges) => {
// do your stuff
});- get recently updated url changes without subscribing
const changes = this.url.changesValue;If you find any issue or have an idea regarding the project and want to share with it, do not hesitate to open a new issue.
Contributions are welcome. Submit a pull request if you want to apply your changes.
Run
ng build
or
npm run build
or
yarn run build
to build the project. The build artifacts will be stored in the dist/ directory.
You can test the project in three ways by running an appropriate script defined in package.json file.
If you want to run disposable tests, run test script.
In case you want to watch for changes in files being tested, run test-watch script.
Or if you want to debug your code in a browser, run test-debug script.
The code is available under the MIT License.