lundi 19 octobre 2015

Using Ember initializers to set domain related data

I have a single Ember app that needs to use different data depending on the domain that it's running on. For example, on domain1.com the site title might be "Domain 1 Website", whereas for domain2.org the site title could be "Cool Site!"

I need to be able to use the data in routes, controllers and templates.

My initializer so far:

import { request } from 'ic-ajax';

export function initialize(container, application) {
  var domain = document.location.host;
  return request('http://api/sites?domain=' + domain, {} ).then(function(response) {
    // make the response available to routes, controllers and templates
  });
}

export default {
  name: 'site-data',
  initialize: initialize
};



Aucun commentaire:

Enregistrer un commentaire