您好我想创建一个自定义对话框组件,我想以声明方式插入它内容,应该如下所示:
app.action.dialog.component.ts:
@Component({ selector: 'app-action-dialog',templateUrl: 'app/template/app.action.dialog.component.html' }) export class ActionDialog { showing: boolean; constructor() { this.showing = false; } show() { this.showing = true; } hide() { this.showing = false; } }
app.action.dialog.component.html:
<div id="overlay" class="valign-wrapper" *ngIf="showing" (click)="hide()"> <div class="container valign"> <div class="card"> <div class="card-content"> <content select="[content]"></content> </div> </div> </div> </div>
用法示例:
<app.action.dialog> <div content> example </div> </app.action.dialog>
这不起作用,我该怎么做?可能吗?
我正确理解你的问题(向另一个组件提供一些内容),我认为你可以利用ng-content:
@Component({ selector: 'field',template: ` <div> <ng-content></ng-content> </div> ` }) export class FormFieldComponent { (...) }
并使用这样的组件:
<field> <input [(ngModel)]="company.address.street"/> </field>
希望它能解读你,蒂埃里
原文地址:https://www.jb51.cc/angularjs/143268.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。