[英]Passing an AngularJS Array to a Downgraded Angular 7 Component
I am working on converting an AngularJS application to Angular. 我正在将AngularJS应用程序转换为Angular。 I am currently running a hybrid solution with most of the components still being AngularJS components, and am slowly rewriting components to Typescript.
我目前正在运行一个混合解决方案,其中大多数组件仍然是AngularJS组件,并且正在缓慢地将组件重写为Typescript。 I am trying to downgrade an Angular component to be used in an AngularJS template, and the component takes in an @Input of a list.
我正在尝试降级要在AngularJS模板中使用的Angular组件,并且该组件采用列表的@Input。
The input declaration in the Angular controller Angular控制器中的输入声明
@Input() inputName: any;
In the AngularJS template: 在AngularJS模板中:
The @Input for this will be the string '$ctrl.list' @Input将是字符串'$ ctrl.list'
<downgraded-component input-name="$ctrl.list"></downgraded-component>
The @Input for this will be an empty string @Input将会是一个空字符串
<downgraded-component input-name="{{$ctrl.list}}"></downgraded-component>
How can I pass a list from an AngularJS component/template to an Angular 7 component/template? 如何将列表从AngularJS组件/模板传递到Angular 7组件/模板?
You need to include brackets []
when passing data that comes from an expression to your angular component, like this; 像这样将来自表达式的数据传递到您的角度组件时,需要包括方括号
[]
;
<downgraded-component [input-name]="$ctrl.list"></downgraded-component>
When using downgraded components you use a strange mix of new and old syntax - the kebab case comes from angularjs and the brackets from angular. 当使用降级的组件时,您会使用新旧语法的奇怪组合-kebab案例来自angularjs,括号来自angular。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.