Angular routing engine that drive views by media types. It loads data itself, and by response Content-Type
header
it displays configured view. It is a replacement for original Angular Router (they cannot be used at the same time).
The aim of this library is to allow building of RESTful clients using Angular, following HATEOAS principle.
See CHANGELOG for release changes.
npm i angular-resource-router --save
See API documentation for latest released version.
Sample snippet how is the router configured. It is very similar to original router, but instead of registering paths, we are registering media types.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ResourceRouterModule } from 'angular-resource-router';
import { AppComponent } from './app.component';
import { SampleComponent } from './sample.component';
import { ErrorComponent } from './error.component';
@NgModule({
declarations: [
AppComponent,
SampleComponent
],
imports: [
BrowserModule,
ResourceRouterModule.configure({
prefix: 'api/'
}),
ResourceRouterModule.forTypes([
{
type: 'application/x.sample',
component: SampleComponent
},
{
status: '*',
type: '*',
component: ErrorComponent
}
])
],
bootstrap: [
AppComponent
]
})
export class ExampleModule {
}
TODO
Build of the library is performed with
npm run build
To publish new library version to npm repository:
- Verify/set library version in
src/lib/package.json
- Make sure there are release notes in the CHANGELOG.
- Commit and push changes, if any
- Create a new release on GitHub,
in the format
v0.0.0
(or alternatively use git directly) - Copy changelog markdown text to the release
- Build the library and make sure all tests passed
npm run build
- Publish the library
npm publish dist/angular-resource-router
- Publish docs, if this is head release
Note: For this command to succeed, you must have ssh agent running at the background.
npm run ghpages
- Merge the branches if needed
Local development server can be started with
npm start
Things that are yet to be implemented
- Complete README
- Complete example
- Support for
resolve
anddata
route configs - Support for
outlet layouts, outlet resolve - Outlet context data (name etc)
- Navigation within outlet
- Hide element if empty link
- External navigation for unknown type
- Build and publish docs
- Typedoc