• [Angular 2] Nesting Elements in Angular 2 Components with ng-content (AKA Angular 2 Transclusion)


    You can place content inside of the instance of your component element then manage it inside of the component’s template using ng-content. This process is called reprojection, but you may be more familiar with the term “transclusion”.

    Home:

    <div>I am home component</div>
    
    <widget-two>
        <widget-one [message]="simpleService.message"></widget-one>
    </widget-two>
    <widget-two>
        This is also widget two
    </widget-two>

    widget-two:

    import { Component, OnInit } from '@angular/core';
    
    @Component({
        moduleId: module.id,
        selector: 'widget-two',
        templateUrl: 'widget-two.component.html'
    })
    export class WidgetTwoComponent implements OnInit {
        constructor() { }
    
        ngOnInit() { }
        
    }
    <h2>Above</h2>
    <ng-content></ng-content>
    <h2>Below</h2>
  • 相关阅读:
    解决CentOS6.5虚拟机克隆后无法上网(网卡信息不一致)的问题
    Linux密码保护
    破解Linux系统开机密码
    Linux常用命令
    人教版中小学教材电子版下载
    作业一
    实验四
    实验一
    实验三
    实验二
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5892568.html
Copyright © 2020-2023  润新知