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

    Using angular.bootstrap to Initialize Your App

    John LindquistJohn Lindquist

    In this lesson, John shows you how to use angular.bootstrap as an alternative approach to initializing your application without using ng-app.

    angularjsAngularJS
    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

    John Lindquist: Angular bootstrap can help you get around the requirement of using ngApp. If I delete this, you can see that I just get this string of curly braces and random.

    What I can do is say "angular.bootstrap" and then look up the elements. I'll get element by ID, and we'll have an element called "container."

    If I say this is an ID of container, then the string will go away there, and the second parameter here is actually the modules you want to pass in. If I pass in my app, which matches up with this, you can see I get the random value back.

    You can actually pass in as many modules as you want in here. This is just going to return the injector that controls each of those modules.

    You can see that if I actually duplicate this and have two separate apps running on the same page...We'll make this one container two and duplicate this line.

    You can see that I'll have two completely separate apps running on different modules and getting different random numbers. They're not sharing the same scope or the same random.

    Discuss

    Discuss