Data binding - lordoftheflies/angular-essential-training GitHub Wiki
Selecting transcript lines in this section will navigate to timestamp in the video
- The Angular framework is much more than just an engine for rendering markup templates through components. One of its strengths is the ease of binding data to views and working with data in those views. The most common way of displaying data in a view template is via interpolation, where you use a set of curly braces around a component property to tell Angular to render the content of that property. You can also use directives, both built-in Angular framework ones and ones you create to help display data. Directives give you the power client-side to add logic to your views, similar to how you would on the server side. The template syntax in Angular is pretty robust and allows you to accomplish a lot of things when it comes to working with data in your views. You can wire up click events to dom elements that modify data that you have displayed elsewhere, and Angular will handle the update of that data visually. There are many elements to the template syntax. In addition to interpolation and built-in directives, the syntax has constructs of patterns such as template expressions and statements, a binding syntax for property, attribute, class, and style bindings, event binding, and template expression operators. You can also create and use local template variables created in markup using the hash to get a reference to the element and then use that from any sibling or child element in the view. This allows you to wire up simple interactions or display related data from within your markup without needing to write any script code. And when it comes to collecting data from the user, Angular has a form module loaded with directives and services for helping you build HTML forms. It provides things like data binding for both setting and getting data, change tracking, validation, and error handling.