is it possible to access attributes set in HTML in an angular.dart constructor?

*爱你&永不变心* 提交于 2020-01-16 01:20:11

问题


I cann´t access the attribute val in the constructor of this component

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

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

which was used in index.html

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

Is there a way to access val in the constructor?


回答1:


Extend NgAttachAware, implement the method attach() and access your field there. When attach() is called your val is already properly initialized.



来源:https://stackoverflow.com/questions/21172775/is-it-possible-to-access-attributes-set-in-html-in-an-angular-dart-constructor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!