vendredi 22 juillet 2016

Where should conditional action logic go?

I am working on a project that uses ember. Conditional logic can be placed in the HTML template, the controller and where the function is define. I have an action that only needs to be fired when a global variable is true.

    <div >...</div>

In the .hbs I can do


   <div >...</div>

   <div>...</div>


or in the function I can

CallThisAction(){
 if(global.x){
    //do something
   }
}

or I could add logic into the controller to prevent the CallThisAction from being called biased off the global.x. Controllers are also depreciated.

I could also pass as param:

CallThisAction(x){
 if(x){
    //do something
   }
}

Is there a cleaner way to do this? Ideally the solution here would be nice:Feature Request




Aucun commentaire:

Enregistrer un commentaire