rksh
rksh

Reputation: 4050

Ember handling multiple returns?

I have two json inputs,

Input 1 :

var status = [{
isLogged : true   
}];

Input2 :

var posts = [{
id: '1',
datalink:124,
isVoted : true,
votecount : 123,
title: "Rails is Omakase",
author: { name: "d2h" },
date: new Date('12-27-2012'),
excerpt: "There are lots of à la carte software environments in this world. Places where in order to eat, you must first carefully look over the menu of options to order exactly what you want."
}]

Everything worked fine when there was one json,

App.Route = Ember.Route.extend({
    model : function(){
    return posts;
    }
});

But when I added the second input it doesn't work

App.Route = Ember.Route.extend({
    model : function(){
    return posts;
    },
    logged : function(){
        return status;
    }
});

How can I get the second input and disply in the html?

{{#if isLogged}}
<li><a href="#">Logout</a></li>
{{else}}
<li><a href="#">Login</a></li>
{{/if}}

Upvotes: 0

Views: 35

Answers (1)

Pascal Boutin
Pascal Boutin

Reputation: 1264

You need to add the second input into your Route's controller.

App.Route = Ember.Route.extend({
    model : function(){
        return posts;
    },
    setupController(controller, model){
        controller.set("model", model);
        controller.set("isLogged", status);
    }
});

And since the isLogged will be declared in the controller, it should be visible within the view.

Upvotes: 1

Related Questions