Angular 如何正确地;“包装”;包含<;模板>;标签?
我试图用我自己的组件包装一个组件,在本例中是一个预处理选取列表,这样我就能够向它添加一个NgModel属性。我跟在后面 因此,Priming picklist允许用户从列表中选择和重新排序项目Angular 如何正确地;“包装”;包含<;模板>;标签?,angular,angular2-template,angular2-forms,primeng,Angular,Angular2 Template,Angular2 Forms,Primeng,我试图用我自己的组件包装一个组件,在本例中是一个预处理选取列表,这样我就能够向它添加一个NgModel属性。我跟在后面 因此,Priming picklist允许用户从列表中选择和重新排序项目 <p-pickList [source]="list1" [target]="list2"> <template let-car> <div class="ui-helper-clearfix"> <img src=
<p-pickList [source]="list1" [target]="list2">
<template let-car>
<div class="ui-helper-clearfix">
<img src="showcase/resources/demo/images/car/{{car.brand}}.gif" style="display:inline-block;margin:2px 0 2px 2px"/>
<div style="font-size:14px;float:right;margin:15px 5px 0 0">{{car.brand}} - {{car.year}} - {{car.color}}</div>
</div>
</template>
</p-pickList>
示例用法(失败)
名称:{{artifact.artifact}
修订版:{{artifact.Revision}
组织:{{artifact.organization}
分支:{{artifact.Branch}
因此,当我在html中传递任何@输入
和@输出
值时,这就起作用了当我试图“通过”带有内容的
标记时,它不起作用,我正在努力找出如何做到这一点
因此,一般的问题是如何正确包装允许使用
标记的自定义组件?(无渲染)也许此解决方案适合您
选择列表表单.component.ts
<form-primeng-picklist
[source]="myList" [target]="artifactorySelectedList" [responsive]="true" [showSourceControls]="false"
[showTargetControls]="false" (onMoveToTarget)="addChecksums($event)" (onMovetoSource)="removeChecksums($event)"
[sourceStyle]="{'height':'300px'}" [targetStyle]="{'height':'300px'}"
[(ngModel)]="testPickList" name="testPickList">
<template let-artifact>
<div class="ui-grid" style="border-bottom:1px solid #D5D5D5;">
<div class="ui-grid-row">
<div class="ui-grid-col-1" style="text-align:center">
<span><i class="fa fa-archive fa-3x" aria-hidden="true"></i></span>
</div>
<div class="ui-grid-col-11">
<span><strong>Name:</strong> {{artifact.artifact}}</span>
<span><strong>Revision:</strong> {{artifact.revision}}</span>
<strong>Organisation:</strong> {{artifact.organisation}}
<strong>Branch:</strong> {{artifact.branch}}
</div>
</div>
</div>
</template>
</form-primeng-picklist>
替换
<template [pTemplateWrapper]="itemTemplate" ></template>
与
因此,您的模板应该如下所示:
<p-pickList ...>
<template let-item>
<template [pTemplateWrapper]="itemTemplate" [item]="item"></template>
</template>
</p-pickList>
<template let-item>
<template [pTemplateWrapper]="itemTemplate" [item]="item"></template>
</template>
<p-pickList ...>
<template let-item>
<template [pTemplateWrapper]="itemTemplate" [item]="item"></template>
</template>
</p-pickList>