加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

在Dart Angular中,如何将函数传递给组件

发布时间:2020-12-17 09:15:55 所属栏目:安全 来源:网络整理
导读:我有一个组件MyComp,我想将一个函数作为参数传递给它. 更确切地说,我想做类似的事情: 飞镖组件文件: @NgComponent( selector: 'mycomp',publishAs: 'ctrl',map: const { 'myfunc' :'= myfunc' } )class MyComponent { Function myfunc; .... myfunc();} HT
我有一个组件MyComp,我想将一个函数作为参数传递给它.
更确切地说,我想做类似的事情:

飞镖组件文件:

@NgComponent(
        selector: 'mycomp',publishAs: 'ctrl',map: const {
          'myfunc' :'=> myfunc'
        }
    )
class MyComponent {
   Function myfunc;

   ....
   myfunc();
}

HTML:

<mycomp myfunc="ctrl.myfunc"></button-list>

问题是myfunc在组件中为null.
我错过了什么吗?我怎样才能做到这一点?

使用’&’将函数绑定到字段:
@NgComponent(
    selector: 'mycomp',map: const {
      'myfunc' :'&myfunc'
    }
)
class MyComponent {
    Function myfunc;

   ....
   myfunc();
}

http://ci.angularjs.org/view/Dart/job/angular.dart-master/javadoc/angular.core/NgComponent.html#map

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读