jeudi 24 septembre 2015

From within an ember component life cycle hook, how can I determine if the component is being invoked in block form?

Per the Ember guides, you can determine if a component is being rendered in block format from within the template using the hasBlock keyword:

// foo-component.hbs
{{#if hasBlock}}
block mode
{{else}}
something else
{{/if}}

How do I do this from within foo-component.js?

import Ember from 'ember';

 export default Ember.Component.extend({
         didInitAttrs: function() {
                 // hasBlock is not defined here
                 if ( this.get('hasBlock') ) {

                 }
         }
 });




Aucun commentaire:

Enregistrer un commentaire