Basic Binding in AngularJS

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 11 years ago
Updated 2 years ago

Binding is a core feature of AngularJS. It provides a simple mechanism for integrating your HTML with your data via {{bracketed expressions}}. In this video, John covers the basics of binding to get you started.

[00:00] Double curly braces and angular represent binding, so anything you put inside of them will be rendered out. A string of hello renders hello. Two plus two renders out four. So a simple hello world might look like hello and then another binding of world.

[00:17] To make this work all you need to do is include the angular script, so just from a CDN or wherever you want to grab it from. The ng-app attribute on the HTML tag, you'll see if I remove ng-app that it no longer renders those out. But if I add it back it renders it out just fine.

[00:36] Let's go ahead and extract this greeting. We'll say, "first.greeting" and move that into an input to something called an ng-model where we say, "first.greeting," meaning that this is a property and then this is an object. We're watching for changes to this property.

[00:55] Whenever this changes and I type something like hello, we get hello world. Bonjour, I get bonjour world. Salutations and so on and so forth. Where it gets really cool is if we start using that to render out into other attributes. If I wrap this with a div and move him up inside the div, add an ng-class and say, "first.greeting here," anything I type in here will apply a CSS class like well or alert, alert-danger.

~ 40 minutes 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

Be on-Topic

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

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