Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Gs1TestTeam opened this issue Aug 16, 2018 · 0 comments
Open

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

Gs1TestTeam opened this issue Aug 16, 2018 · 0 comments

Comments

@Gs1TestTeam
Copy link
Owner

Gs1TestTeam commented Aug 16, 2018

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant