博客
关于我
Angular开发(六)-关于组件之间的数据交互
阅读量:143 次
发布时间:2019-02-26

本文共 2521 字,大约阅读时间需要 8 分钟。

? Angular ????????????????????????????????????

???????????????

??????????????????????????????????????????????????????

??? HTML:

  • { {item.name}}----{ {i+1}}--{ {item.id}}
  • ??? TypeScript:

    dataSet = [  { id: 0, name: "??" },  { id: 1, name: "??" },  { id: 2, name: "??" }];bar(event: any) {  console.log(event);}

    ??? HTML:

    ??? TypeScript:

    @Input() names: any = {};@Output() foo = new EventEmitter
    ();todo(event: any) { this.foo.emit('??');}

    ????? emit ??????????????????????????????

    ???????????????

    ? Angular ???????????????????????

    ??? HTML:

  • ??? TypeScript:

    dataSet = [  { id: 0, name: "??" },  { id: 1, name: "??" }];

    ??? TypeScript:

    @Input() names: any = {};childFn() {  console.log("???????");}

    ?? #father ?????????????????????

    ???? @ViewChild ???????

    ??????????????????????????????

    ??? TypeScript:

    @ViewChild(ChildComponent) child: ChildComponent;father() {  this.child.childFn();}

    ??? HTML:

  • ?????????

    ????????????????????????

    ??? TypeScript:

    private com1ToCom2: any;appFn(event: any) {  console.log(event);  this.com1ToCom2 = event;}

    ???? HTML:

    ??? TypeScript:

    @Input() com2: string = "";

    ???????????

    ????? Angular ?????????????????????

    ??? TypeScript:

    import { Component, OnInit } from '@angular/core';@Component({  selector: 'app-father1',  templateUrl: './father1.component.html',  styleUrls: ['./father1.component.css']})export class Father1Component implements OnInit {  public name: string = "????????";  public dataSet: any[] = [    { id: "0", name: "??" },    { id: "1", name: "??" },    { id: "2", name: "??" }  ];  constructor() {}  ngOnInit() {}}

    ??? TypeScript:

    import { Component, OnInit } from '@angular/core';import { Father1Component } from "app/father1/father1.component";@Component({  selector: 'app-child1',  templateUrl: './child1.component.html',  styleUrls: ['./child1.component.css']})export class Child1Component implements OnInit {  constructor(private father1: Father1Component) {}  ngOnInit() {}}

    ??? HTML:

    { father1.name }

    • { item.name }

    ??????

    ? Angular ?????????????????????? set ??????????

    ??? HTML:

    ??? TypeScript:

    import { Component, OnInit } from '@angular/core';@Component({  selector: 'app-comdemo01',  templateUrl: './comdemo01.component.html'})export class Comdemo01Component implements OnInit {  _input: string;  @Input() public set input(v: string) {    this._input = v.toUpperCase();    console.log(v);  }  public get input(): string {    return this._input;  }  constructor() {}  ngOnInit() {}}

    ??? HTML:

    I am fron { input }

    转载地址:http://vpvf.baihongyu.com/

    你可能感兴趣的文章
    NIFI大数据进阶_连接与关系_设置数据流负载均衡_设置背压_设置展现弯曲_介绍以及实际操作---大数据之Nifi工作笔记0027
    查看>>
    NIFI数据库同步_多表_特定表同时同步_实际操作_MySqlToMysql_可推广到其他数据库_Postgresql_Hbase_SqlServer等----大数据之Nifi工作笔记0053
    查看>>
    NIFI汉化_替换logo_二次开发_Idea编译NIFI最新源码_详细过程记录_全解析_Maven编译NIFI避坑指南001---大数据之Nifi工作笔记0068
    查看>>
    NIFI集群_内存溢出_CPU占用100%修复_GC overhead limit exceeded_NIFI: out of memory error ---大数据之Nifi工作笔记0017
    查看>>
    NIFI集群_队列Queue中数据无法清空_清除队列数据报错_无法删除queue_解决_集群中机器交替重启删除---大数据之Nifi工作笔记0061
    查看>>
    NIH发布包含10600张CT图像数据库 为AI算法测试铺路
    查看>>
    Nim教程【十二】
    查看>>
    Nim游戏
    查看>>
    NIO ByteBuffer实现原理
    查看>>
    Nio ByteBuffer组件读写指针切换原理与常用方法
    查看>>
    NIO Selector实现原理
    查看>>
    nio 中channel和buffer的基本使用
    查看>>
    NIO基于UDP协议的网络编程
    查看>>
    NISP一级,NISP二级报考说明,零基础入门到精通,收藏这篇就够了
    查看>>
    Nitrux 3.8 发布!性能全面提升,带来非凡体验
    查看>>
    NI笔试——大数加法
    查看>>
    NLog 自定义字段 写入 oracle
    查看>>
    NLog类库使用探索——详解配置
    查看>>
    NLP 基于kashgari和BERT实现中文命名实体识别(NER)
    查看>>
    NLP 项目:维基百科文章爬虫和分类【01】 - 语料库阅读器
    查看>>