lundi 20 avril 2015

What is wrong with this Ember.js handlebars if statement?

Hi i have an ember app with a handlebars if else statement that always shows the if part and never the else

I have read everything i can in the ember documentation here and here and searched the net countless times:(

The code for my controller and template appear below i think the problem may have something to do with my session initializer that my controller references not being loaded before my controller?

I have read here and here and many other places i have forgotten:( trying to learn how to get my initializer loaded before my controller

Below is the code for my application controller and my application template

 <nav role="navigation" class="navbar navbar-default navbar-fixed-top">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            {{#link-to "index" class="navbar-brand"}}Hide The Word{{/link-to}}
        </div>
        <!-- Collection of nav links and other content for toggling -->
        <div id="navbarCollapse" class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
              {{#if 'registered'}}
                <li>{{#link-to "user" userId}}{{user}}{{/link-to}}</li>
                <li>{{#link-to "logout"}}Logout{{/link-to}}</li>
              {{else}}
                <li>{{#link-to "login" class = "navbar-right"}}{{user}}{{/link-to}}</li>
                <li>{{#link-to "login" class = "navbar-right"}}Sign In{{/link-to}}</li>
              {{/if}}
              <button{{action 'test'}}>test</button>
            </ul>
        </div>
    </div>
  </nav>
{{outlet}}

application.js

import Ember from 'ember';

export default Ember.Controller.extend({
    user:function(){
        if(this.get('session').authed){
            var provider = this.get('session').authData.auth.provider,
            name = this.get('session').authData[provider].displayName;
            return name;
        }else{
            return 'Hi Guest'
        }
    }.property(),

    registered:function(){
        if(this.get('session').authed){
            return true;
        }
        else{
            return false;
        }
    }.property(),
});




Aucun commentaire:

Enregistrer un commentaire