Exposing the title to a post menu button

(Steven Slade) #1

Continuing the discussion from I want to move the Facebook and Twitter share buttons to post menu:

I have passed along the title of a topic to a post menu button action by reopening the Topic Controller and giving a variable access to the model.title. I then use the variable in api.attachWidgetAction.

var topicTitle;
      const TopicController = api.container.lookupFactory('controller:topic');
        _titleChanged: function() {
          const title = this.get('model.title');
          topicTitle = this.get('model.title');
          if (!Ember.isEmpty(title)) {

            // Note normally you don't have to trigger this, but topic titles can be updated
            // and are sometimes lazily loaded.
            topicTitle = this.get('model.title');
        }.observes('model.title', 'category')

Does anyone have a better way of getting a Topic’s title to use in a plugin’s initializer?