1

おそらく何人かの人々は答えを知っているだけですが、私は次のことを理解しようとしています:

ビューを宣言しているとしましょう。

App.FooView = Ember.View.extend({});

このビューをで参照するApp.Routerと、次のエラーが発生します。

router.get('applicationController').connectOutlet('Foo')

Fooを参照すると、コンソールの状態は次のようになります。Uncaught Error: assertion failed: The name you supplied Foo did not resolve to a controller FooController

引数を説明しているドキュメントのどこにも見つかりませんでした。おそらく、反対票を投じた人が実際に解決策に貢献する可能性があります。

4

1 に答える 1

1

コンセントを接続すると、ルータは、提供されたものと同じ名前のコントローラとビューの両方を探します。リストした例では、ルーターはFooControllerとFooViewを探していますが、コントローラーを見つけていません。詳細を指定する場合は、次のように、ビュー、コントローラー、およびコンテキストを含むオプションオブジェクトを渡すことができます。

router.get('applicationController').connectOutlet( {
           outletName: 'master',
           controller: 'fooController',
           view: 'fooView',
           context: data
        }); 

ドキュメントから:

connectOutlet: function(name, context) {
// Normalize arguments. Supported arguments:
//
// name
// name, context
// outletName, name
// outletName, name, context
// options
//
// The options hash has the following keys:
//
//   name: the name of the controller and view
//     to use. If this is passed, the name
//     determines the view and controller.
//   outletName: the name of the outlet to
//     fill in. default: 'view'
//   viewClass: the class of the view to instantiate
//   controller: the controller instance to pass
//     to the view
//   context: an object that should become the
//     controller's `content` and thus the
//     template's context.

編集:文法とコード形式

于 2012-08-06T18:39:51.947 に答える