项目作者: ng-hal

项目描述 :
A navigator for HAL documents in Angular
高级语言: TypeScript
项目地址: git://github.com/ng-hal/ng-hal.git
创建时间: 2016-08-21T15:01:13Z
项目社区:https://github.com/ng-hal/ng-hal

开源协议:MIT License

下载


ng-hal

npm version
npm downloads
License
Dependencies Status
Peer Dependencies Status

Greenkeeper
CircleCI
Travis CI
Codecov coverage on master

A navigator for HAL documents in Angular

Usage

  1. $ npm install --save ng-hal

Alternative, use yarn:

  1. $ yarn add ng-hal

Import HalModule.forRoot() to your application’s module:

  1. import { HalModule } from 'ng-hal';
  2. @NgModule({
  3. imports: [
  4. HttpModule,
  5. HalModule.forRoot()
  6. ]
  7. })
  8. export class AppModule {}

Inject Navigator into components or services, then start retrieving HAL/JSON documents:

  1. import { Navigator } from 'ng-hal';
  2. @Injectable()
  3. export class Foo {
  4. constructor(
  5. private navigator: Navigator
  6. ) {}
  7. demo() {
  8. this.navigator
  9. .get('/my/hal-document.json')
  10. .subscribe((doc: Document) => console.log(doc));
  11. }
  12. }

Demo application

http://spektrakel.de/ng-hal

API Design Considerations

  • Navigator API is almost identical to Angular’s Http API.
    • follow is a short-cut Observable operation that is derived from mergeMap/flatMap.
  • Document gives you a Resource object and the original Request/Response pair.
  • Resource is a normalized view of the JSON document. You can, however, obtain the unmodified JSON object.

Reading List

Credits