Importing What we Need

Before we use an external function or class, we define where to find it. We do that with:
+ import statement
+ import allows us to use exported members from external ES module
+ import from third party library, our own ES modules or from Angular

We can import from Angular because it is modular. There is a collection of library modules. Each library is itself a module made up of several related feature module. Some of the Angular library module are:
+ @angular/core
+ @angular/animate
+ @angular/http
+ @angular/router

You can view more angular library packages at: https://www.npmjs.com/~angular

Completed Component
import { Component } from '@angular/core';

@Component({
  selector: 'pm-root',
  template: `
  <div>
    <h1>{{pageTitle}}</h1>
    <div>My First Component</div>
  </div>
  `
})
export class AppComponent {
    pageTitle: string = 'Acme Product Management';
}

where,
'import' is import keyword
'Component' is member name
'@angular/core' is angular library / module name

Share this

Related Posts