Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

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

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

    No Custom Markup

    John LindquistJohn Lindquist

    Extending the semantics of HTML is one of the core features of AngularJS, however, you can use AngularJS without any custom markup.

    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: While we're on the subject of using Bootstrap and sort of NG app to initialize your app, it's worthwhile to mention, even though I don't recommend this practice, that you don't have to use any custom elements or attributes at all for your directives.

    If I were to create a controller, like an app controller -- we'll say "math.random", you might wonder, "Where am I going to put this controller if I can't use ng controller?" The way you could use this is if you use a directive. We'll just call this "app", and we'll return an object which restricts to a class -- you may see where I'm going now with controller of app control as app.

    From here if I simply give this a class of app and then look up my app.random this way, that should work the exact same way. You could build your whole application using classes for your directives, setting up controllers through your classes, whether just using the controller or linking functions and everything that you'd typically use in a directive.

    You could have a completely clean dom with no ngApp, no ng controller, no ng anything and still use the bindings and everything you're used to. Again, I don't recommend that way. I prefer my dom to be more descriptive of what the app is actually doing, but if this is the way you really want to do it, it is an option.

    Discuss

    Discuss