Render Multiple View / Controller Pairs

I am currently submitting a list of views:

<ul> {{#each newsItem in controller}} {{view App.NewsItemView contentBinding="newsItem" class="news-item" }} {{/each}} </ul> 

But I would like to introduce NewsItemController in every view.

I tried using render , but it looks like this only supports one view, providing an exception:

Missed error: steering column error: could not find the 'control' property on the object.

I found a brief mention of using control instead, but it no longer seems to be included.

So how can I visualize multiple versions of the same view by inserting a separate controller into each of them?

+1
source share
1 answer

{{render}} should be fixed in the current main (if you build it from Github). You can use it several times if you pass the model:

 <ul> {{#each controller}} {{render "newsItem" this}} {{/each}} </ul> 

{{control}} still exists, but is hidden behind the flag (because it is still experimental). To use it, you need to do: ENV.EXPERIMENTAL_CONTROL_HELPER = true before including the ember.js file. If you can avoid using it, it would be better.

However, I think the simplest approach would be to use itemController :

 <ul> {{#each controller itemController="newsItem"}} {{view App.NewsItemView class="news-item" }} {{/each}} </ul> 

I think you can combine them to simplify (I have not tried it yet):

 <ul> {{each controller itemController="newsItem" itemViewClass="App.NewsItemView"}} </ul> 
+1
source

All Articles