63. Directives vs Components
Components are simplified Directives
Components have a MUCH simpler configuration object
Components will generally accomplish everything you need
You still need directives when you need to do DOM manipulation or create a class based
directive
Advanced functionality such as terminal, priority, etc require a directive
64. Basic Component Structure
The basic structure for a component is module.component('name', { });
Notice that unlike a directive, component takes a configuration object and not
a function
The most common component configuration properties will be controller,
template, templateUrl and bindings
65. Component Driven Architecture
Components only control their own View and Data
Components have a well-defined public API aka Inputs and Outputs
Components have a well-defined lifecycle
A well architected application is a tree of components
89. Component Lifecycle Hooks
Components have well defined lifecycle hooks that allow us to perform specific
operations during the lifespan of our component
We can use $onInit to know when our controller has been has been constructed
and its bindings initialized
We can also use $onInit to know when a dependent component is available
We can use $onDestroy to perform clean when our component is removed
95. Isolated Scope
Isolated scope secures the perimeter of your component so that you can
control what goes in and out
Isolated scope is great for defining an API to your directive
There are now four ways to interact with isolated scope: via an attribute, one-
way binding, two-way binding or an expression
96. Inputs and Outputs
Inputs are denoted with an < or @ symbol
Outputs are denoted with an & symbol
@ indicates an attribute binding which is one-way and string based
< indicates a one-way binding that is object based
& is an expression binding which fires a callback on the parent component