Skip to content

How to pass message from a view to a class​ #1

Open
@Gs1TestTeam

Description

@Gs1TestTeam

Pass data from a view page like this:

<app-blue-box 
    [message]="'Test Message'"
>
</app-blue-box>

Receive data using Input Directive like this:

import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'app-blue-box',
  templateUrl: './blue-box.component.html',
  styleUrls: ['./blue-box.component.css']
})
export class BlueBoxComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

  @Input() message: string; // <-- the "message" property available for binding, can receive message 'Test Message' from view
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions