ngx-url v2.1.0
NgxUrl
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.
Installation
NPM:
npm install ngx-urlYarn:
yarn add ngx-urlUsage
Use 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;Issues
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.
Contributing
Contributions are welcome. Submit a pull request if you want to apply your changes.
Development
Build
Run
ng buildor
npm run buildor
yarn run buildto build the project. The build artifacts will be stored in the dist/ directory.
Test
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.
License
The code is available under the MIT License.