Dart聚合物,访问Custom属性在脚本中返回null

时间:2014-01-04 13:17:08

标签: dart dart-polymer polymer

我将客户端作为参数发送到自定义客户端后续详细信息(在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: []

1 个答案:

答案 0 :(得分:3)

ClientFollowupDetail实例可能未被聚合物完全初始化。

create代码移到ready

的覆盖内容可能会有所帮助
ready() {
  super.ready();
  eventBus = getInstanceEventBus();
  print(client.names);
}