# Accessing model out of load order

**URL:** <https://meta.discourse.org/t/accessing-model-out-of-load-order/96661>\
**Category:** Development\
**Created:** [9월 7, 2018, 4:49오후 UTC](https://meta.discourse.org/t/accessing-model-out-of-load-order/96661 "2018-09-07T16:49:11Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)\
**Post date:** [9월 7, 2018, 4:49오후 UTC](https://meta.discourse.org/t/accessing-model-out-of-load-order/96661/1 "2018-09-07T16:49:11Z")

</div>

Hey all, I’m trying to work through an issue in the `user-private-messages` controller in a theme.

Here’s what I’m trying to do.

- In the `user/messages` template, add content if there are fewer than 5 private messages in the list.  
Example:

```plaintext
{{#if showMessagesCTA}}
   <p>Hey here I am!</p>
{{/if}}

```

- I’m modifying the `user-private-messages` controller to add the `showMessagesCTA` method, as this appears where the template pulls logic from. The data I need is in the `user-topics-list` model, in particular the `topics` array.  
Example:

```plaintext
api.modifyClass("controller:user-private-messages", {
    showMessagesCTA: function() {
        let userTopicsListModel = api.container.lookup("controller:user-topics-list").get('model');
        if (userTopicsListModel && userTopicsListModel.topics){
             return userTopicsListModel.topics.length() < 5;
        } else {
             return false;
        }
    }.property()
});

```

The problem I’m running into is the model always returns `null`. I’m guessing this is a timing issue because the `user-private-messages` controller loads prior to `user-topic-list`. When I log just the `user-topics-list` controller, it shows up but is greyed out. Clicking into it shows all the data, but it’s clearly not accessible in the app.

 ![Clipboard%20-%20September%207%2C%202018%2011-03%20AM](https://global.discourse-cdn.com/meta/original/3X/0/2/02d1f5ab014a5eca636a0a69a15947d3c86cdcb7.png)

Is there a better way to approach accessing this data I’m not accounting for?

---

_[View the full topic](https://meta.discourse.org/t/accessing-model-out-of-load-order/96661)._
