Ember renderTemplate relay model

前端 未结 1 1104
你的背包
你的背包 2021-01-21 17:16

Working hard on my Ember app here, and it\'s going along fine. However, I\'ve run into an issue of unexpected behaviour and I\'m not sure regarding the best approach to this pro

相关标签:
1条回答
  • In the renderTemplate method you're telling Ember to render a template inside an outlet but it will just default the controller to the one managing the route. Given it's the controller handling the route it makes sense that it manages all the templates within that route.

    Of course you can specify a different controller using:

    this.render("test", {
        outlet: "left",
        controller: 'test'
    });
    

    it can in turn be a controller you already instantiated (and maybe set its content):

    var testController = this.controllerFor('test');
    testController.set(....)
    this.render("test", {
        outlet: "left",
        controller: testController
    });
    

    About using the model: You can call this.modelFor('test') inside the route and it will return the model of the test route (it even knows if it has already been resolved). I usually do this when I need to access the model of one of the parent routes.

    I believe it makes sense to access the model of a parent route, but not so much if you're accessing the model of an unrelated route. Why don't you want to merge both models?

    0 讨论(0)
提交回复
热议问题