This Lesson is for Members

Subscribe today and get access to all lessons! Plus direct HD download for offline use, enhances transcripts, member comment forums, and iTunes "podcast" RSS feed. Level up your skills now!

Unlock This Lesson

Already subscribed? Sign In

Autoplay

    Set Values on Generated Angular 2 Templates with Template Context

    John LindquistJohn Lindquist

    Angular 2 templates have a special let syntax that allows you to define and pass a context when they’re being generated.

    angularAngular
    2 - 6
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    00:00 Most templates don't have inputs, and there's no real way to push the data in from a line like this. What you do is you set these let statements, these let attributes. If I say let description, then that description can live in here. We'll say description, that'll render that out. Copy and paste that here as well, then you say this attribute will be equal to description.

    00:28 This one is going to come off what's called a context for this template. The context is the second parameter, so if I say description is sweet, hit save. Now every time I click create template, you'll see sweet come through because sweet's being passed in the context. You can read the context values off of here, pass them into the let declarations, and then those are rendered out. So keep on clicking, sweet, sweet, sweet. It's sweet templates all the way down.

    Discuss

    Discuss