博客
关于我
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/

    你可能感兴趣的文章
    Queue
    查看>>
    PL/SQL Developer中文版下载以及使用图解(绿色版)
    查看>>
    pl/sql developer乱码,日期格式等问题解决
    查看>>
    PL/SQL 中的if elsif 练习
    查看>>
    PL/SQL 存储函数和过程
    查看>>
    query简单入门到精通细节 - (六)Jquery效果之“淡入与淡出”
    查看>>
    PL/SQL提示“ORA-01722:无效数字,将无效数字查找出来
    查看>>
    PL/sql语法单元
    查看>>
    PL/SQL连接远程服务器数据库,出现ORA-12154: TNS: 无法解析指定的连接标识符。
    查看>>
    pl/sql锁
    查看>>
    PL2303 Windows 10 驱动项目常见问题解决方案
    查看>>
    QueryPerformanceCounter与QueryPerformanceFrequency
    查看>>
    Plaid.com的监控系统如何实现与9600多家金融机构的集成
    查看>>
    Plain Stock Prediction:基于RNN的股票价格预测工具
    查看>>
    platform_driver与file_operations两种方法开发led驱动
    查看>>
    PlatON共识方案详解:应用CBFT共识协议,提高共识效率
    查看>>
    QueryDict和模型表知识补充
    查看>>
    Querybase 使用与安装教程
    查看>>
    Playwright与Selenium的对比:谁是更适合你的自动化测试工具?
    查看>>
    quarz设置定时器任务的有效时间段_定时器?你知道有几种实现方式吗?
    查看>>