Skip to content

Instantly share code, notes, and snippets.

@trumbitta
Last active March 29, 2019 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trumbitta/6cb3a943b5e9fa9406920e9bc7d4561b to your computer and use it in GitHub Desktop.
Save trumbitta/6cb3a943b5e9fa9406920e9bc7d4561b to your computer and use it in GitHub Desktop.
Angular for dads - Intro to components: passing data
import { Component, Input } from '@angular/core';
@Component({
selector: 'ng4d-greeting-card',
template: `
<article>
<h1>Hello, I'm {{ name }}!</h1>
<p>And I'm a {{ age }} years old dad.</p>
</article>
`,
styles: [
`
article {
width: 30%;
margin: 2rem auto;
padding: 1rem 2rem;
font-family: sans-serif;
border: 1px solid #cccccc;
}
h1 {
font-family: serif;
margin: 0 0 1rem 0;
}
p {
margin: 0;
}
`,
],
})
export class GreetingCardComponent {
@Input() name: string;
@Input() age: string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment