アプリケーションコントローラー、アプリケーションビュー、プラグインして操作するビュータイプ、および外部データを処理する無関係のコントローラーを備えたember.jsルーターアプリケーションを想定しています。その3番目のビューは、無関係のコントローラーから計算されたプロパティをどのように.property()
取得できますか?変更が通知されるように、楕円に何を入力しますか?
例えば
App.ExternalDataController = Em.Controller.extend
stellarProperty: 'super value' #I want OtherView to have a computer property referencing this
App.ApplicationController = Em.ArrayController.extend
content: [] #Assume a bunch of values of some kind here
App.ApplicationView = Em.View.extend
templateName: 'app-view'
App.OtherView = Em.View.extend
templateName: 'other-view'
someComputedProperty: (->
App.router.externalDataController.get('stellarProperty') + ' flying pigs'
).property() #What do I put in that property elipses?
テンプレート
<script type="text/x-handlebars" data-template-name="application">
<div>
{{#each content}}
{{name}} -- {{view App.OtherView}}
{{/each}}
</div>
</script>
<script type="text/x-handlebars" data-template-name="other-view">
<span>Irate goats and {{view.someComputedProperty}}</span>
</script>