<talk-cmp [talk]="someExp" (rate)="eventHandler($event.rating)">
import {Component} from "@angular/core";
@Component({
selector: "my-father",
templateUrl: "father.html"
})
export class FatherComponent {
data: Array<Object>;
constructor() {
this.data = [
{
"id": 1,
"name": "html"
},
{
"id": 2,
"name": "css"
},
{
"id": 3,
"name": "angular"
},
{
"id": 4,
"name": "ionic"
},
{
"id": 5,
"name": "node"
}
]
}
}
<h1>父组件</h1> // 包含子组件, 并使用属性传递数据过去 <my-child [info]="data"></my-child>
import {Component, Input} from "@angular/core";
@Component({
selector: "my-child",
templateUrl: "child.html"
})
export class ChildComponent {
// 使用@Input获取传递过来的数据
@Input()
info: Array<Object>;
constructor() {
}
}
<ul>
<li *ngFor="let item of info">
{{item.name}}
</li>
</ul>
import {Component, OnInit, Output, EventEmitter} from "@angular/core";
export class ThreeLinkComponent {
province: string;
// 输出一下参数
@Output() provinceOut = new EventEmitter();
constructor() {
this.province = "陕西";
}
}
provinceChange() {
// 选择省份的时候发射省份给父组件
this.provinceOut.emit(this.province);
}
<!--三级联动组件--> <three-link (provinceOut)="recPro($event)"></three-link>
// 函数接受子函数传递过来的变量, 子函数中emit的时候触发这个函数。
recPro(event) {
this.province = event;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有