Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Set Values on Generated Angular 2 Templates with Template Context

    2 - 6

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



    Become a Member to view code

    You must be a Pro 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
    orLog In




    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.

    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.