Angular 7 Interview Questions – Set 01

What is Angular framework?

Angular is a TypeScript-based open-source web framework and a platform. It is used to build web/ mobile and desktop applications.

Main features of this framework are: Declarative templates, dependency injection, end to end tooling etc. These features make web development easy in Angular.

What is the UrlSegment Interface in Angular 7?

In Angular 7, the UrlSegment interface represents a single URL segment, constructor, properties and methods like this:

class UrlSegment {
constructor(path: string, parameters: {…})
path: string
parameters: {…}
toString(): string
}
The UrlSegment is a part of a URL between the two slashes and it contains a path and matrix parameters associated with the segment.

What are the new features added in Angular7?

Following is a list of new features added in Angular7:

  • Angular7 displays an elegant look in the new update.
  • It provides virtual scrolling by using the scrolling package .
  • It facilitates you to use drag and drop property by using the @angular/cdk/drag-drop module.
  • In Angular7, libraries make changes to itself automatically with the updated version of the Material design.
  • Angular7 provides better error handling for @Output if property is not initialized.
  • Angular7 provides added support for Node v10.

What is the difference between structural directive and attribute directive in Angular 7?

Structural directives are used to alter the DOM layout by removing and adding DOM elements. These directives are far better in changing the structure of the view. Examples of Structural directives are NgFor and Nglf.

Attribute Directives are used as characteristics of elements. For example, a directive such as built-in NgStyle in the template Syntax guide is an attribute directive.

What is Do Bootstrap (ng Do Bootstrap) In Angular 7?

The ng Do Bootstrap is a new life-cycle hook added in Angular 7 and Do Bootstrap is an interface.

What is the difference among “declarations”, “providers” and “import” in NgModule?

Difference among declarations”, “providers” and “import” in NgModule:

  • declarations are used to make directives (including components and pipes) from the current module available to other directives in the current module. Selectors of directives, components or pipes are only matched against the HTML if they are declared or imported.
  • providers are used to make services and values known to DI. They are added to the root scope and they are injected to other services or directives that have them as dependency. A special case for providers is lazy loaded modules that get their own child injector. Providers of a lazy loaded module are only provided to this lazy loaded module by default (not the whole application as it is with other modules).
  • import makes the exported declarations of other modules available in the current module.

What are directives in Angular7?

In Angular7, directives are used to add behavior to an existing DOM element or an existing component instance.

What are the key components of Angular?

Key components of Angular:

Components: Components are the basic building blocks of angular application and used to control HTML views.

Modules: Modules are the set of angular basic building blocks like component, directives, services etc. An application is divided into logical pieces and each piece of code is called as “module” and used to perform a single task.

Templates: Templates are used to represent the views of an Angular application.

Services: It is used to create components which can be shared across the entire application.

Metadata: This can be used to add more data to an Angular class.

What are components in Angular7?

Components are the basic building blocks of an Angular app formed like a tree structure. Components are subset of directives but unlike directives, components always have a template and only one component can be instantiated per an element in a template.

Explain the Architecture overview of Angular.

Angular is the most popular web development framework for developing mobile and web applications. It uses cross platform mobile development called IONIC that’s why it is not limited to web apps only.

There are 7 main building blocks of an Angular application:

  • Component
  • Templates
  • Metadata
  • Data Binding
  • Directives
  • Services
  • Dependency Injection
    The basic building blocks of an Angular application are NgModules, which provide a compilation context for components. Angular app is defined by a set of NgModules and it always has at least a root module that enables bootstrapping, and many more feature modules.