// create Ember js app
App = Ember.Application.create();
// Create a grand parent view - without using templateName function/property
App.GrandparentView = Ember.View.extend({
click: function() {
console.log('Grandparent!');
}
});
// Create a parent view by using templateName function/property
App.ParentView = Ember.View.extend({
templateName:"parent-view",
click: function() {
console.log('parent view!');
}
});
// use the template to render the view content
<script type="text/x-handlebars" >
{{#view App.GrandparentView}}
Click Grandparent View!
{{/view}}
</script>
// embed the view inside a div
<div id="Parent">
<script type="text/x-handlebars">
{{view App.ParentView}}
</script>
</div>
这两种不同的方法在 ember.js 中的视图渲染方面是如何工作的。哪一个更可取,一个比另一个的用例或优势是什么。