# Best Practice: "Master-Detail App"

**URL:** <https://forum.ionicframework.com/t/best-practice-master-detail-app/57370>\
**Category:** ionic-v1\
**Created:** [July 13, 2016, 1:08pm UTC](https://forum.ionicframework.com/t/best-practice-master-detail-app/57370 "2016-07-13T13:08:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simsal](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Simsal](https://forum.ionicframework.com/u/Simsal)\
**Post date:** [July 13, 2016, 1:08pm UTC](https://forum.ionicframework.com/t/best-practice-master-detail-app/57370/1 "2016-07-13T13:08:09Z")

</div>

Hi guys,

in my App i´m displaying data from about 2000 stores.

When the App gets opened, it shows the data summed up (For example total revenue, number of open stores, number of purchases, …). That part is already working nicely.

But then i´m displaying a list with every store. On selecting one of these items, the app should be showing only the data of this store.

My first idea was using the $rootScope. On the one hand, it didn’t work as i hoped, on the other hand i read, that using $rootScope is bad practice.

Currently i’m stuck. Would appreciate every hint and idea!

Greetings 🙂

---

<div class="post-metadata">

**Author:** ![jiffer](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jiffer](https://forum.ionicframework.com/u/jiffer)\
**Post date:** [July 13, 2016, 1:30pm UTC](https://forum.ionicframework.com/t/best-practice-master-detail-app/57370/2 "2016-07-13T13:30:14Z")

</div>

Use a factory.  
Place this in your app.js

```
.factory('storeService', function() {
  var oStore = '';

  return {
    getStore: function () {
      return oStore;
    },
    setStore: function (oNewStore) {
      oStore= oNewStore;
    }
  };
});

```

And in your controller:

```
.controller(MasterCtrl, function($scope, storeService)
   storeService.setStore(oClickedStore);

.controller('DetailCtrl', function($scope, storeService)
    $scope.oStore = storeService.getStore();
```

---

<div class="post-metadata">

**Author:** ![Simsal](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Simsal](https://forum.ionicframework.com/u/Simsal)\
**Post date:** [July 14, 2016, 6:30am UTC](https://forum.ionicframework.com/t/best-practice-master-detail-app/57370/3 "2016-07-14T06:30:42Z")

</div>

Thank you @jiffer .

Clean and simple… And i can always check, if a store is already set.

I get the impression that for most questions the answer is: “use a factory” 😃
