No Custom Markup

AngularJS Video Tutorial by

Enter Your Email Address to Watch This Lesson

Your link to unlock this lesson will be sent to this email address.

Unlock this lesson and all 193 of the free egghead.io lessons, plus get AngularJS content delivered directly to your inbox!



Existing egghead subscribers will not see this. Sign in.

Just one more step!

Check your inbox for an email from us and click link to unlock your lesson.




Edit

No Custom Markup

1:39 AngularJS lesson by

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

Find the code for this lesson on JSBin.

egghead.io comment guidelines

egghead.io
Avatar

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

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.


Related lessons: