1

私の Ember アプリには、ユーザーがいるアプリのセクションに応じて表示する必要があるいくつかの異なるメニューまたはナバーがあります。これを行うにはどのような方法が推奨されますか? 私がやろうとしていたのは、テンプレートにビューを含めることでした:

{{view App.NavbarView controllerBinding="App.CurrentNavbarController.nav"}}

そして私の見解では、パスをチェックしています:

App.NavbarView = Ember.View.extend({ 
    templateName: function() {
        path = App.getPath('router.currentState.path');
        //change navbar
    }
});

それが私が立ち往生しているところです。ビューを動的に切り替えるにはどうすればよいですか?

4

2 に答える 2

0

1 つの方法は、ルーターを使用して設定することです。

someRoute:
  connectOutlets: (router, model)->
     # ... normal stuff here
     App.set 'section', 'theNameOfThisSection'
  exit: (router)->
     App.set 'section', ''

  subRoute:
    # ... in the sub route, App.section will still be set
于 2012-12-15T14:21:46.670 に答える
0

もう 1 つの方法は、ルーターを使用していくつかのコンセントを Nav ビューに接続することです。

application.handlebars名前付きアウトレットを配置します。

{{outlet nav}}

ルーターで、ルートを入力するときにコンセントを接続します。

userRoute: 
  connectOutlets: (router, model)->
    # normal stuff here
    router.get('applicationController').connectOutlet('navbar', 'userNav', model)
  exit: (router)->
    router.get('applicationController').disconnectOutlet 'navbar'

  subRoute:
    # still has the navbar outlet connected in a subroute
于 2012-12-15T14:26:55.307 に答える