No Custom Markup

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 11 years ago
Updated 5 years ago

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.

egghead
egghead
~ an hour ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today