Transcript
Page 1: Using a hypermedia API with Angular.js

1

Using a hypermedia API with Angular.js

Pieter Herroelen

Page 2: Using a hypermedia API with Angular.js

2

Pieter Herroelen

Page 3: Using a hypermedia API with Angular.js

3

Pieter Herroelen @piether

Page 4: Using a hypermedia API with Angular.js

4

Pieter Herroelen @piether

AE

Page 5: Using a hypermedia API with Angular.js

5

Project

Page 6: Using a hypermedia API with Angular.js

6

Flexible UI

Page 7: Using a hypermedia API with Angular.js

7

First approach

"municipality": {

"criteria": {

"groups": [["LABEL“,"POSTAL_CODE"]],

“label": {

"type": "TEXT_MEDIUM",

"operators": "ALPHA",

"common": true,

"mandatory": false

},

},

Page 8: Using a hypermedia API with Angular.js

8

First approach

CLIENT SERVER

CONFIG

DATA

Page 9: Using a hypermedia API with Angular.js

9

First approach

http://www.youtube.com/watch?v=62RvRQuMVyg

Page 10: Using a hypermedia API with Angular.js

10

Richardson maturity model

http://martinfowler.com/articles/richardsonMaturityModel.html

Page 11: Using a hypermedia API with Angular.js

11

Page 12: Using a hypermedia API with Angular.js

12

Richardson maturity model

http://martinfowler.com/articles/richardsonMaturityModel.html

Page 13: Using a hypermedia API with Angular.js

13

Hypermedia

CLIENT SERVER HYPERMEDIA

Page 14: Using a hypermedia API with Angular.js

14

Hypermedia

CLIENT SERVER JSON over HTTP

Page 16: Using a hypermedia API with Angular.js

16

Hypermedia

CLIENT SERVER HYPERMEDIA

Content-type: application/hal+json

Page 17: Using a hypermedia API with Angular.js

17

Hypermedia

Content-type: application/hal+json

SPEC

Page 18: Using a hypermedia API with Angular.js

18

Hypermedia

Content-type: application/hal+json

SPEC

CLIENT SERVER

Page 19: Using a hypermedia API with Angular.js

19

Which specification?

Page 20: Using a hypermedia API with Angular.js

20

Page 21: Using a hypermedia API with Angular.js

21

Page 23: Using a hypermedia API with Angular.js

23

HAL

Page 24: Using a hypermedia API with Angular.js

24

"_links": {

"self": { "href": "/orders"}

},

"currentlyProcessing": 14,

"shippedToday": 20,

"_embedded": {

"ea:order": [

{

"_links": {

"self": { "href": "/orders/123" },

"ea:basket": { "href": "/baskets/98712" }

},

"total": 30.00

}

...

Page 25: Using a hypermedia API with Angular.js

25

"_links": {

"self": { "href": "/orders"}

},

"currentlyProcessing": 14,

"shippedToday": 20,

"_embedded": {

"ea:order": [

{

"_links": {

"self": { "href": "/orders/123" },

"ea:basket": { "href": "/baskets/98712" }

},

"total": 30.00

}

...

Page 26: Using a hypermedia API with Angular.js

26

"_links": {

"self": { "href": "/orders"}

},

"currentlyProcessing": 14,

"shippedToday": 20,

"_embedded": {

"ea:order": [

{

"_links": {

"self": { "href": "/orders/123" },

"ea:basket": { "href": "/baskets/98712" }

},

"total": 30.00

}

...

Page 27: Using a hypermedia API with Angular.js

27

Page 28: Using a hypermedia API with Angular.js

28

EPiaAACBSwaADEtPoHTMD

<resource uri=“http://example.com/path”> ...

Page 29: Using a hypermedia API with Angular.js

29

JSON $scope

• properties • links • embedded

objects

Page 30: Using a hypermedia API with Angular.js

30

JSON $scope

• properties • links • embedded

functions

Page 31: Using a hypermedia API with Angular.js

31

follow() Replace content of directive with resource behind link

Example: <a ng-click=“links[‘children’].follow()”></a>

Page 32: Using a hypermedia API with Angular.js

32

function(method, data) Do an HTTP call with the specified method and the specified data in the request. Returns a promise.

Example:

$scope.links[‘save’](‘POST’, $scope.form).then(...);

Page 33: Using a hypermedia API with Angular.js

33

HAL

CLIENT SERVER

Page 34: Using a hypermedia API with Angular.js

34

HAL

CLIENT SERVER

LINK RELATIONS

Page 35: Using a hypermedia API with Angular.js

35

JSON $scope

• properties • links • embedded

Recursive structure

Page 36: Using a hypermedia API with Angular.js

36

JSON $scope

• properties • links • embedded

property • header

HTML

Page 37: Using a hypermedia API with Angular.js

37

JSON $scope

• properties • links • embedded

property • header

HTML

<ng-include

src=“property+’.html’”>

</ng-include>

Page 38: Using a hypermedia API with Angular.js

38

http://www.x17online.com/gisele-elephant.jpg

Page 39: Using a hypermedia API with Angular.js

39

Where is the model?

Page 40: Using a hypermedia API with Angular.js

40

http://www.x17online.com/gisele-elephant.jpg

Page 41: Using a hypermedia API with Angular.js

41

QUESTIONS?


Top Related