What is an Angular View?

Ole Ersoy
1 min readFeb 11, 2019

--

Photo by Drew Graham on Unsplash

Scenario

Reading through various tutorials we see the term View frequently and we would like to know what this refers to in general.

Concept

The View is something we route to. For example suppose our HomeComponent is routed to like this:

path:'home', component: HomeComponent

The template rendered by the HomeComponent is the View

Architectural Analysis

The View is the internal data structure that a component uses to represent itself and perform change detection.

For example for our AppComponent will have an AppComponentView that corresponds to the <app-component> dom element (declared component selector).

If that element is routed to then that’s a View.

When creating a components dynamically using a factory the View or Host View can be imperatively accessed like this:

helloComponentRef:ComponentRef = helloComponentFactory.create();
view: ViewRef = helloComponentRef.hostView;

--

--

Ole Ersoy
Ole Ersoy

Written by Ole Ersoy

Founder of Firefly Semantics Corporation

No responses yet