我想從bucket-modal.component.ts
顯示彈出當在list.component.ts
用戶鼠標懸停/鼠標離開。 如何list.component.ts
之間的溝通bucket-modal.component.ts
?我的代碼在這裏。如何將子組件傳遞給父代兄弟組件?
list.component.ts
@Component({
selector: 'list',
templateUrl: 'list.component.html',
styleUrls: ['list.component.css'],
})
export class ListComponent implements OnInit {
@Input() state: boolean;
@Output() toggle = new EventEmitter();
onHover() {
this.state = true;
this.toggle.emit(this.state);
console.log("state is ----------" + this.state);
}
onHoverOut() {
this.state = false;
this.toggle.emit(this.state);
console.log("state is------ " + this.state);
}
}
list.component.html
<a (mouseover)="onHover()" (mouseleave)="onHoverOut()">random Link list</a>
listdetails.component.ts
@Component({
selector: 'app-list-detail',
templateUrl: 'app-list.component.html',
styleUrls: ['app-list.component.css'],
})
export class ListDetailComponent implements OnInit {
}
listdetails.component.html
<list [elementslist]="listdetails" listingtype="3"></list>
<list [elementslist]="listdetails" listingtype="3"></list>
<list [elementslist]="listdetails" listingtype="3"></list>
<bucket-modal [(showMeaddBucket)]="show2ClickedBucket" [state]="PopUpshow" (toggle)="PopUpshow=$event"></bucket-modal>
鬥modal.component.ts
@Component({
selector: 'bucket-modal',
templateUrl: 'bucket-modal.component.html',
styleUrls: ['bucket-modal.component.css'],
})
export class BucketModalComponent implements OnInit {
@Input() state: boolean;
@Output() toggle = new EventEmitter();
onHover() {
this.state = true;
this.toggle.emit(this.state);
console.log("state is " + this.state);
}
onHoverOut() {
this.state = false;
this.toggle.emit(this.state);
console.log("state is " + this.state);
}
}
我想通過id來鬥模型組件。怎麼做? – vel
你可以實現'showDialog()'方法來接受一個參數 - 這個ID。 –
未調用showDialog對話框。 'showDialog():void { console.log(「test」); }' – vel