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.
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
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!