ionic framework - How to print a specific item's title after clicking on their link -


hey wondering if me out in how can print specific item's title after clicking on link. code default menu start:

in mainpage have:

<ion-view view-title="main">     <ion-content>         <ion-list>             <ion-item ng-repeat="page in sidepages" href="#/abstractmain/mainpage/{{page.id}}">                 {{page.title}}             </ion-item>         </ion-list>     </ion-content> </ion-view> 

each item linked page view:

<ion-view view-title="page">     <ion-content>        <!-- display {{page.title}} -->          <h1>hello</h1>     </ion-content> </ion-view> 

and controller sidepages is:

.controller('pagectrl', function($scope){   $scope.sidepages = [     { title: 'name 1', id: 1 },     { title: 'name 2', id: 2 },     { title: 'name 3', id: 3 },     { title: 'name 4', id: 4 },     { title: 'name 5', id: 5 },     { title: 'name 6', id: 6 }   ]; }); 

i'm not sure how show each sidepages title when click @ page, because right print "hello". there way or have rethink design?

i think should rethink design. here 1 possible way:

  1. create service holds pages.

  2. create 2 controllers: 1 page list , 1 opened page. inject created service both controllers. have access array of pages through service.

  3. you add getall() , get(id) method service. it's straightforward these doing, right?

  4. in controller of pagelist: $scope.sidepages = pagesservice.getall() , controller of single page: $scope.page = pagesservice.get(id). find id of opened page in $stateparams object (you need inject in controller).

i hope enough started @ least.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -