アプリケーション テンプレート内にフラッシュ (メッセージ) ビューを実装しました。アプリケーションの msg 属性を使用して、サイト全体のメッセージを表示します。
<div class='application-main container'>
{{#if msg}}
{{view Yu.FlashView}}
{{/if}}
{{outlet}}
</div>
私のルーターの一部:
Yu.Router.map ->
@resource 'user', { path: '/users/:user_id' }
そしてユーザールート:
Yu.UserRoute = Em.Route.extend
model: (params) ->
Yu.User.find(params.user_id)
setupController: (controller, model) ->
@_super controller, model
@controllerFor('avatar').set 'model', model.get('avatar')
@controllerFor('basicinfo').set 'model', model.get('basicinfo')
renderTemplate: (controller, model) ->
@_super controller, model
@render 'avatar', into: 'user', outlet: 'avatar'
@render 'basicinfo', into: 'user', outlet: 'basicinfo'
ユーザールートに入るとわかるように、basicinfoコントローラーをセットアップしてアウトレットに入れました。質問は次のとおりです。basicinfoコントローラーにアプリケーションコントローラーが「必要」ですが、機能していないようです:
Yu.BasicinfoController = Em.ObjectController.extend
needs: 'application'.w()
update: ->
@content.save()
@content.on('becameInvalid', ->
window.console.log(Em.inspect(@get('controllers.application'))) !-> prints "undefined"
@get('controllers.application').set 'msg', 'please refresh' !-> msg did not show
)
@set 'inEditModel', false
そして、私は必要なAPIと非常に混乱しています.ここで何が問題なのですか? ありがとう!