samedi 24 mars 2018

How to load model data i application template for authenticated users

I followed ESA dummy app example steps to implement implicit grant authentication. It works fine, but I wonder how to proceed in the below situation: - usually we define navbar, in the application template - application.js route is defined like that - I need to load all the shops in a drop-down list in the navbar of application template only if a user us authenticated. - in application.hbs template I defined the select list as follows:


        <li class="nav-item">
          <select>
            
              <option value=></option>
            
          </select>
        </li>
      

  • if I add a model hook to the application.js router:

    model() {
        if (this.get("session.isAuthenticated")) {
          return this.store.findAll('shop');
        }
      },
    
    

it works, but I have to refresh the page to have the drop-down list populated. Any ideas ? Thank you.




Aucun commentaire:

Enregistrer un commentaire