1

カスタム client-followup-detail (home.html 内) にクライアントをパラメーターとして送信し、その情報を "client_followup_detail.html" に表示しますが、"client_followup_detail.dart" からクライアント属性にアクセスしようとすると、例外が発生します。

home.html

<template repeat="{{index in extraTabsIndex}}">
  <template if="{{activeTab == index}}">
    <div class="tab-pane fade in active">
      <p>
         <client-followup-detail client="{{clientSelect}}"></client-followup-detail>
      </p>
    </div>
 </template>

client_followup_detail.html

<td>{{client.state}}</td>
<td>{{client.cellphone}}</td>
<td>{{client.lastContactDate}}</td>

client_followup_detail.dart

  @published Client client;  
  ClientFollowupDetail.created() : super.created() {
    eventBus = getInstanceEventBus();
    print(client.names);    //  client null
  }

エラー:

Exception: The null object does not have a getter 'names'.
NoSuchMethodError : method not found: 'names'
Receiver: null
Arguments: []
4

1 に答える 1

3

ClientFollowupDetail インスタンスは、ポリマーによって完全に初期化されていない可能性があります。

createコードを次のオーバーライドに移動すると役立つ場合がありreadyます。

ready() {
  super.ready();
  eventBus = getInstanceEventBus();
  print(client.names);
}
于 2014-04-11T23:19:32.210 に答える