jeudi 25 juin 2015

ember.js runtime resolver not working

I'm new to ember.js (but I know MVC from my CakePHP experiences and JS as well) and in the last 2 weeks I build a little app at work which loads sideloaded JSON data with the REST-Adapter. I added some buttons with actions and everything works fine and I learned a lot, but it takes time to figure out the details.

All my controllers, routes and models are not organised at the moment in a folderstruture which is described in the ember.js-Guide: http://ift.tt/1fIkmtN

Now I want to move the files to the folderstructure. But then the application does not work. It seems to my that the resolver can not finde the files at runtime. But why?

An easy example which does not work:

in "app.js" (loaded with -tag in "index.html"):

App = Ember.Application.create({
    LOG_RESOLVER: true // just for debugging
});

in "router.js" (loaded with -tag after "app.js" in "index.html"):

App.Router.map(function(){
  this.route('mytest');
});

in "routes/mytest.js":

export default Ember.Route.extend({
  setupController: function(controller) {
    controller.set('title', "Hello world!");
  }
});

in "controllers/mytest.js":

export default Ember.Controller.extend({
    appName: 'mytest'
});

in "indes.html":

<script type="text/x-handlebars">
    {{#link-to 'mytest' }}Mytest{{/link-to}}<br/>
    {{outlet}}
</script>
<script type="text/x-handlebars" id="mytest">
  mytest Template
  <h1>appName: {{appName}}</h1>
  <h2>title: {{title}}</h2>
</script>

The Handlebar-template "mytest" is showen, but {{appName}} and {{title}} are empty. If I moved the "mytest"-Template to "templates/mytest.hbs" nothing is showen.

Seems to my that the resolver does not work. Or something wrong with the naming-conventions Guide?

My another assumption: Resolver-Stuff only works when using a buildprocess like in ember-cli.

Using "ember-1.12.1.debug", "ember-template-compiler-1.12.1"

Thanks for help.




Aucun commentaire:

Enregistrer un commentaire