Menu Close

angular interview questions

What is Angular?

  • Angular is a TypeScript-based open-source web application framework, developed and maintained by Google.
  • It offers an easy and powerful way of building front end web-based applications.
  • Angular integrates a range of features like declarative templates, dependency injection, end-to-end tooling, etc. that facilitates web application development.

Please explain the various features of Angular?

  • Accessibility Applications
  • Angular CLI
  • Cross-Platform App Development
  • Code Generation
  • Code Splitting
  • Synergy with Popular Code Editors and IDEs
  • Templates
  • Testing

Could you explain services in Angular?

  • Singleton objects in Angular that get instantiated only once during the lifetime of an application are called services.
  • An Angular service contains methods that maintain the data throughout the life of an application.
  • The primary intent of an Angular service is to organize as well as share business logic, models, or data and functions with various components of an Angular application.
  • The functions offered by an Angular service can be invoked from any Angular component, such as a controller or directive.

What are Angular expressions?

  • Angular expressions are code snippets that are usually placed in binding such as {{ expression }} similar to JavaScript.
  • These expressions are used to bind application data to HTML
  • Syntax: {{ expression }}

What are templates in Angular?

  • Templates in Angular 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.

In Angular what is string interpolation?

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

What do you understand by controllers in Angular?

  • Controllers are JavaScript functions which provide data and logic to HTML UI.
  • As the name suggests, they control how data flows from the server to HTML UI.

 What are directives in Angular?

  • A core feature of Angular, directives are 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
    • Attribute Directives

What is data binding?

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

What is the purpose of a filter in Angular?

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

What is a provider in Angular?

  • A provider is a configurable service in Angular.
  • It is an instruction to the Dependency Injection system that provides information about the way to obtain a value for a dependency.
  • It is an object that has a $get() method which is called to create a new instance of a service.
  • A Provider can also contain additional methods and uses $provide in order to register new providers.

What is the difference between $scope and scope in Angular?

  • $scope in Angular is used for implementing the concept of dependency injection (D.I) on the other hand scope is used for directive linking.
  • $scope is the service provided by $scopeProviderwhich can be injected into controllers, directives or other services whereas Scope can be anything such as a function parameter name, etc.

Explain jQLite?

  • jQlite is also known as jQuery lite is a subset of jQuery and contains all its features.
  • It is packaged within Angular, by default. It helps Angular to manipulate the DOM in a way that is compatible cross-browser.
  • jQLite basically implements only the most commonly needed functionality which results in having a small footprint.

What is transclusion in Angular?

  • The transclusion in Angular allows you to shift the original children of a directive into a specific location within a new template.
  • The ng directive indicates the insertion point for a transcluded DOM of the nearest parent directive that is using transclusion.
  • Attribute directives like ng-transclude or ng-transclude-slot are mainly used for transclusion.

What is the difference between a link and compile in Angular?

  • Compile function is used for template DOM Manipulation and to collect all the directives.
  • Link function is used for registering DOM listeners as well as instance DOM manipulation and is executed once the template has been cloned.