我有一个父组件和一个子组件。父组件可以如下所示:
<button (click)="popupState = true>Click this to get a popup</button>
<popup-component [popupState]="popupState"></popup-component>
在ts文件中包含:
import { Component, OnInit} from '@angular/core';
@Component({
selector: 'parent-
我将通过父组件中的一个按钮动态地添加子组件。它可以很好地工作,我可以添加多少我想要的孩子,但一旦我删除最后一个孩子(刚刚添加),添加一个新的孩子不再工作了。
我就是这样做的:
parent.ts
import {Component,DynamicComponentLoader,ElementRef,AfterViewInit,Injector} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {ChildComponent} from '.
我已经搜索过了,但未能整合到我的项目中。
**问题:**我必须从component.ts向component.ts发送一个变量contains number。注意:我不想在HTML页面中使用这个值。下面我给出了一个示例,我多么想要这些数据!
child.component.ts
===================
export class Child{
x:number;
<!-- may be some code to send the x value-->
<!-- Remember the value is in a method,which is onclick