
Question. What Is @inputs In Angular 2?
Answer :
@Input allows you to pass data into your controller and templates through html and defining custom properties. This allows you to easily reuse components and have them display different values for each instance of the renderer.
Question. What Is @outputs In Angular?
Answer :
Components push out events using a combination of an @Output and an EventEmitter. This allows a clean separation between reusable Components and application logic.
Question. What Are the Differences Between Components And Directives?
Answer :
Components :
- For the register component, we use @Component meta-data annotation.
- The component is a directive that use shadow DOM to create encapsulated visual behavior called components. Components are typically used to create UI widgets.
- A component is used to break up the application into smaller components.
- Only one component can be present per DOM element.
- @View decorator or templateURL template is mandatory in the component.
Directives :
- For register directives, we use @Directive meta-data annotation.
- Directives are used to add behavior to an existing DOM element.
- The directive is used to design reusable components.
- Many directives can be used in a per DOM element.
- The directive doesn’t have View.
Question. What Is Aot Compilation?
Answer :
AOT compilation stands for Ahead Of Time compilation, in which the angular compiler compiles the angular components and templates to native JavaScript and HTML during the build time. The compiled Html and JavaScript is deployed to the web server so that the compilation and render time can be saved by the browser.
Question. What Are The Core Differences Between Observables And Promises?
Answer :
Promises vs Observables :
Promises:
- returns a single value.
- not cancellable.
Observables:
- works with multiple values over time.
- cancellable.
- supports map, filter, reduce and similar operators.
- proposed feature for ES 2016.
- use Reactive Extensions (RxJS).
- an array whose items arrive asynchronously over time.