Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you want to access a view's property from a template, you have to prefix with "view." In your example: <code>{{#if view.logged}}</code>.</p> <p>You can't do <code>App.mainV.test()</code> because <code>App.mainV</code> is a class, not an instance. You could do <code>App.mainV.create().test()</code>.</p> <p>And you should rename <code>App.mainV</code> to <code>App.MainV</code> to fit Ember.js conventions (class names should be capitalized, see <a href="http://www.emberist.com/2012/04/09/naming-conventions.html" rel="noreferrer">http://www.emberist.com/2012/04/09/naming-conventions.html</a>)</p> <p><strong>Edit</strong>:</p> <p>There's another problem in your example: the controller tries to modify a value in the view. In the Ember way, you should bind a view's property to the controller. Any change in the controller would be propagated to the view:</p> <pre><code>&lt;script type="text/x-handlebars"&gt; {{#view App.MainView}}     {{#if view.logged}}         Hey!     {{else}}         &lt;!-- Login form here when clicked: App.mainController.login()--&gt;     {{/if}} {{/view}} &lt;/script&gt;​ App = Ember.Application.create(); App.mainController = Ember.Controller.create({ logged: false, login: function() { this.set('logged', true); } }); App.MainView = Ember.View.extend({ loggedBinding: 'App.mainController.logged' }); // change in controller will be propagated to the view App.mainController.set('lo​gged', true);​​​​​​ </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload