How does conditional works?

Hi guys, i’m new and like to get some help.
I got two buttons which will execute next and previous function when clicked in the {{if}} statement.

So basically if it is the last page, next button will hide, and previous button will hide in the first page.

But after trying, seems like the view only render once, so the new boolean is not being read, and thus the buttons is not hid even the boolean is false.

And btw how can I call the function in the same controller?
Like calling bgImg in,
I tried this.send(‘bgImg’); but no luck.

Any help is appreciated.

Codes below:


{{#if notMin}}
  <button {{action 'previous'}}></button>
{{#if notMax}}
  <button {{action 'next'}}></button>


App.ApplicationController = Ember.Controller.extend({
  frameIndex: 1,
  frameSize: 5,
  notMin: false,
  notMax: true,

  actions: {
    next: function(){
      this.notMin = true;

        console.log("Last page reached!");  
      }else if(this.frameIndex==this.frameSize-1){
        this.notMax = false;

   previous: function(){
     this.notMax = true;

       console.log("First page reached!");  
     }else if(this.frameIndex==2){
       this.notMin = false;

   bgImg: function(){
     var head = "background-image:url('images/";
     var img = jsondata[this.frameIndex-1].bgimg;
     var end = "')";
     return head+img+end;

Don’t forget to use .get and .set on Ember object properties.

this.set('notMin', true);
this.set('notMax', false);
if (this.get('frameIndex') == ...


1 Like

Work like a charm,
thanks a lot Splattne!

You’re welcome! Bonus tip: for ++ there is incrementProperty

1 Like

Is there any disadvantage using the native ++?

You can’t use ++ on .get('...')