javascript - SetupController for Component Ember -


i have component adds class 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 in specific route need set isvisible: true

i know in ember can access route controller setupcontroller if want set isvisible: true component?

if not possible , there other ways achieve it? maybe inside component itself?

this sounds problem resolved through ember.service. can go in couple ways, more straightforward might inject service component , bind isvisible.

something like:

export default ember.service.extend({   isvisible: false });  export default ember.component.extend({   visibility: ember.inject.service(),   isvisible: ember.computed.alias('visibility.isvisible') });  export default ember.route.extend({   visibility: ember.inject.service(),    aftermodel() {     this.set('visibility.isvisible', true);   } }); 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -