【问题标题】:is it possible to access attributes set in HTML in an angular.dart constructor?是否可以在 angular.dart 构造函数中访问 HTML 中设置的属性?
【发布时间】:2014-01-21 08:48:53
【问题描述】:

我无法访问该组件构造函数中的属性 val

@NgComponent(
    selector: 'dartcomp',
    templateUrl: 'dartComp.html',
    publishAs: 'ctrl',
    map: const
    { 
      'val' : '@val'
    }
)
class DartComp
{ String val;

  DartComp()
  { print("construktor DartComp $val");
  }
}

在 index.html 中使用过

<dartcomp id="dc" val="x"></dartcomp>

有没有办法在构造函数中访问 val?

【问题讨论】:

标签: dart angular-dart


【解决方案1】:

扩展NgAttachAware,实现attach() 方法并在那里访问您的字段。当attach() 被调用时,您的val 已经正确初始化。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-07-06
  • 2014-12-10
  • 2012-12-25
  • 2023-04-02
  • 1970-01-01
  • 1970-01-01
  • 2016-08-06
相关资源
最近更新 更多