0

I have some json which is being ng-repeated:

{
"title": "image title",
"description": "Lorem ipsum dolor sit amet, per ea ferri platonem voluptaria, ea eum ubique ornatus interpretaris. Dolore erroribus reprimique ex mea, mei soluta iisque cu, cu eam repudiare iracundia. Te cum populo molestie noluisse. Cu graece propriae eum, at qui erat oportere, ad wisi consequat persecuti pri. Ne usu partem discere, quas aliquam id cum. Tation numquam sensibus pri ne, his cibo noluisse scriptorem in.",
"imageUrl": "http://some.url.com",
"tags": "Apple, Orange, Banana, Pear, Grapes, Peach",
"owner": "some name",
"thumbnailUrl": "http://some.url.com"
},

On the index page it only shows the thumbnailUrl, if you click on the image it should pass that object to a new 'page'/template and display the description/author etc.

I've tried using various examples and none of which seem to work as I want. Quite confused and any help would be awesome.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
invmatt
  • 123
  • 3
  • 8

1 Answers1

1

If you are using some sort of router, you can pass this object to the new page, or like code90 said, you can use a service to maintain these objects between pages.

EDIT: Here is a link to the ui-router page

https://angular-ui.github.io/ui-router/site/#/api/ui.router

holtc
  • 1,780
  • 3
  • 16
  • 35
  • I'm using ngRoute if that helps – invmatt Sep 06 '16 at 21:39
  • change to use ui-router, it is more fully featured. Then you can use $state.go("stateNmae", param) when the image is clicked, where "stateName" is the name of the state you wish to go to, and the param object would be the object you wish to pass – holtc Sep 06 '16 at 21:42
  • You don't happen to have a quick and dirty example by any chance? Fairly new to Angular and I'm still getting my head around it all. Cheers. – invmatt Sep 06 '16 at 22:11
  • This page should provide some color: http://stackoverflow.com/questions/20632255/angularjs-pass-an-object-into-a-state-using-ui-router – holtc Sep 07 '16 at 02:45