I will be making a list of intermediate to advanced interview questions, then listing their answers here.
- What is Angular?
- Why use Angular?
- What is Angular used for?
- What are Angular components?
- What are Angular expressions?
- What are Angular templates?
- What are Angular directives?
- In Angular, what is string interpolation?
- In Angular, what’s different between Annotations and Decorators?
- What is Scope in Angular?
- What is data binding in Angular?
- Why have a filter in Angular?
Here are my answers!
- Angular is an open-source front-end web framework that provides a platform for easy development of web-based single page applications (SPAs) and empowers developers in curating cross-platform applications. It integrates features like declarative templates, dependency injection and various other best practices that streamlines the development path.
- There are numerous benefits to using Angular:
- It supports two-way data-binding
- It follows MVC pattern architecture
- It supports static template and Angular template
- You can add a custom directive
- It also supports RESTful services
- Validations are supported
- Client and server communication is facilitated
- Support for dependency injection
- Has features like Event Handlers, Animation, etc.
- Angular is typically used for the development of SPA which stands for Single Page Applications. Angular provides a set of ready-to-use modules that simplify the development of single page applications. Not only this, with features like built-in data streaming, type safety, and a modular CLI, Angular is regarded as a full-fledged web framework.
- Components are building block in an Angular application. Components are defined using the @component decorator. A component has a selector, template, style and other properties, using which it specifies the metadata required to process the component.
- Angular expressions are code snippets that are usually placed in binding such as Syntax: {{ expression }} similar to JavaScript. These expressions are used to bind application data to HTML.
- Angular templates are written with HTML that contains Angular-specific elements and attributes. These templates are combined with information coming from the model and controller which are further rendered to provide the dynamic view to the user.
- Angular directives are a core feature of Angular, attributes that allow you to write new HTML syntax, specific to your application. They are essentially functions that execute when the Angular compiler finds them in the DOM. The Angular directives are segregated into 3 parts: Component Directives, Structural Directives, and Attribute Directives.
- String interpolation in Angular is a special syntax that uses template expressions within double curly {{ }} braces for displaying the component data. It is also known as moustache syntax. The JavaScript expressions are included within the curly braces to be executed by Angular and the relative output is then embedded into the HTML code. These expressions are usually updated and registered like watches, as a part of the digest cycle.
- Annotations in angular are “only” metadata set of the class using the Reflect Metadata library. They are used to create an “annotation” array. On the other hand, decorators are the design patterns that are used for separating decoration or modification of a class without actually altering the original source code.
- Scope in Angular is an object that refers to the application model. It is an execution context for expressions. Scopes are arranged in a hierarchical structure which mimics the DOM structure of the application. Scopes can watch expressions and propagate events.
- In Angular, data binding is one of the most powerful and important features that allow you to define the communication between the component and DOM(Document Object Model). It basically simplifies the process of defining interactive applications without having to worry about pushing and pulling data between your view or template and component. In Angular, there are four forms of data binding:
- String Interpolation
- Property Binding
- Event Binding
- Two-Way Data Binding
- Filters in Angular are used for formatting the value of an expression in order to display it to the user. These filters can be added to the templates, directives, controllers or services. Not just this, you can create your own custom filters. Using them, you can easily organize data in such a way that the data is displayed only if it fulfills certain criteria. Filters are added to the expressions by using the pipe character |, followed by a filter.