Skip to content
Loading
0
  • Amit Kumar Singh
    0
    Hello
           I have different component 
             1.AppComponent
             2.RoomComponent 
     
    I have to pass value from AppComponet to RoomComponent.
     
     
    Thanks
    0
  • Jitendra Kumar
    0
    TypeScript
    import {Component,EventEmitter} from "@angular/core"; import {User} from "User.Model";  @Component({    selector: 'component-A',    outputs :["selectedUser"],    templateUrl:'' })  export class AppComponent{  selectedUser : new EventEmitter;  public rowSelected:boolean = true;  constructor(public users : User ) {}  getRowData(rowIndex: number, rowData: any): void {          this.rowSelected = $(rowIndex).hasClass('selected');         console.log(rowData);         this.users= rowData.FirstName;         this.selectedUser.emit(this.users);     } }

    Component B Html

    Component B.ts

    Code
    // skipping some code export class BComponent{      PrintUserInfo(user :User): void {        console.log("Name :" + user.Name);    } }
    0
  • Bhairab Dutt
    0
    Hi ,
     
    There are 2 scenerios :
     
    If one is Parent component and other as child component then you can pass the value to child using @input 
     
    and if component has not the relation ship of parent and child then you can use angular service for sharing the data .
     
    I think , According to your question you can use the @input deccorator .
     
     Hope its helps to you.
    Thanks
    0