angularjs – 将函数从angular1传递到降级的angular2分量
发布时间:2020-12-17 17:08:55 所属栏目:安全 来源:网络整理
导读:问题: 我无法获得成功传递给降级的Angular 2组件的功能.我已经尝试了几乎所有我认为可以传递的方法,但我只能通过字符串插值传递字符串 – 一些属性= {{controller.property}}.以下是我尝试过的一些事情(是的,我知道其中一些没有意义……) some-function="co
问题:
我无法获得成功传递给降级的Angular 2组件的功能.我已经尝试了几乎所有我认为可以传递的方法,但我只能通过字符串插值传递字符串 – >一些属性= {{controller.property}}.以下是我尝试过的一些事情(是的,我知道其中一些没有意义……) some-function="controller.function"; some-function="{{controller.function}}"; //<-- works for data,not functions [some-function]="{{controller.function}}"; [someFunction]="controller.function"; [(someFunction)]="controller.function"; 建立: 这是我现有的设置,它适用于数据,但不适用于功能: Angular 1用法 <my-component data-input-name="{{controller.name}}"></my-component> 升级/降级适配器 angular.module('myModule').directive('myComponent',downgradeComponent({ component: MyComponent,inputs: ['inputName'] }) as angular.IDirectiveFactory); Angular 2定义 @Component({ selector: 'my-component',templateUrl: './my.component.html',styleUrls: ['./my.component.css'] }) export class MyComponent implements OnInit { @Input() inputName: any; constructor() {} } Angular docs甚至展示了如何设置,但他们没有给出任何实际使用的例子. 解决方法
像这样使用AngularJS kebab案例,似乎对我有用:
<my-component [data-input-name]="controller.name"> </my-component> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Angular http post请求内容类型从’text / plain’到’appl
- 我可以在没有使用scala-native的JVM的情况下运行我的scala程
- angularjs – 文本输入框不接受来自Angular UI Bootstrap的
- scala – 如何在spark sql中执行多行sql
- bootstrap 起步
- .Net remoting, Webservice,WCF基础
- 推荐Vim插件用于C编码?
- vim – 如何复制到剪贴板3最后一行来自:messages
- Scala DoubleLinkedList中的当前元素是什么?
- Visual Rules规则引擎 + WebService简单的项目案例【连载一