dimanche 1 novembre 2015

SetupController for Component Ember

I have a component which adds a class for an animation after 5 seconds

export default Ember.Component.extend({
    tagName: 'div',
    classNames: ['gears'],
    isVisible: false,

    _startTimer: Ember.on('didInsertElement', function () {
        var _this = this;

        this._visibleTimer = Ember.run.later(this, function () {
            _this._visibleTimer = null;
            _this.set('isVisible', true);
        }, 5000);
    }),

    _endTimer: Ember.on('willDestroyElement', function () {
        if (this._visibleTimer) {
            Ember.run.cancel(this, this._visibleTimer);
        }
    })
});

<i class="fa fa-cog fa-fw big {{if isVisible 'fa-counter'}}"></i>

My Problem is that in a specific a Route i need to set isVisible: true

I know that in Ember we can access by the route to the controller by setUpController but what if i want to set isVisible: true for a Component?

If this is not possible , are there other ways to achieve it? Maybe inside the component itself?




Aucun commentaire:

Enregistrer un commentaire