1

我将客户端作为参数发送到自定义客户端跟踪详细信息(在 home.html 中)并在“client_followup_detail.html”中显示它们的信息,但是当我尝试从“client_followup_detail.dart”访问客户端属性时发生异常。

主页.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 回答