前端input和output

来源:互联网 发布:淘宝怎么关注宝贝 编辑:程序博客网 时间:2024/06/06 05:25
//data接收了父组件的输入
@Input("pie-data")data;
// Output一般都是一个EventEmitter的实例,使用实例的emit方法将参数emit到父组件中,触发父组件的childEvent事件。

@Output() childEvent =newEventEmitter<any>();

import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';import * as d3 from 'd3';@Component({    selector: 'app-root',    templateUrl: './app.component.html',    styleUrls: ['./app.component.css']})export class AppComponent implements OnInit {    data1;    data2;    ngOnInit() {        this.data1 = [10, 20, 50, 30, 80];        this.data2 = [1, 2, 5, 3, 8]; }

import { Component, OnInit, Input,Output,EventEmitter, ElementRef } from '@angular/core';import * as d3 from 'd3';@Component({    selector: 'd3-pie',    templateUrl: './d3-pie.component.html',    styleUrls: ['./d3-pie.component.css']})export class D3PieComponent implements OnInit {    //data接收了父组件的输入    @Input("pie-data") data;    constructor(private elRef:ElementRef) { }    ngOnInit() {      ……


http://blog.csdn.net/u014291497/article/details/60970792

原创粉丝点击