Last active
March 29, 2019 12:23
-
-
Save trumbitta/6cb3a943b5e9fa9406920e9bc7d4561b to your computer and use it in GitHub Desktop.
Angular for dads - Intro to components: passing data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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