Template Development Helper Log

  • Post author:
  • Post category:EmberJS
  • Post comments:1 Comment
helper

You can display the output variables in the context of browser’s console by using the {{log}} helper. With this helper, you can also receive the primitive types such as strings or numbers.

Syntax

{{log 'Statment' VarName}}

Example

The example given below shows how to render an output to the browser’s console. Create a component with the name post-action and add the following code to it −

import Ember from 'ember';

export default Ember.Component.extend ({
   actions: {
      send() {
         this.toggleProperty('isShowingBody');
      }
   }
});

Now open the post-action.hbs file created under app/templates/components/ with the following code −

<h2>Log Helper</h2>
{{#if isShowingBody}}
   {{log 'Name is:' firstName}}
{{/if}}

{{input type = "text" placeholder = "Enter the text" 
   value = firstName disabled = entryNotAllowed}}
<button {{action "send"}}>Submit</button>
{{yield}}

Open the index.hbs file, which is created under app/templates/ with the below code −

{{post-action}}
{{outlet}}

Previous Page:-Click Here

This Post Has One Comment

Leave a Reply