0

So i m following the angular tutorial here and at the same time i m also reading about modules here. Now inside the tutorial at some point, the author introduces this import:

import { Component, OnInit } from '@angular/core';

I could not find anywhere what the @ sign is in the above import. I mean what '@angular/core' suppose to do?

  • 2
    It's just the name of the package. The various Angular packages all have that prefix; see e.g. [scoped packages](https://docs.npmjs.com/misc/scope). – jonrsharpe Mar 22 '18 at 20:53

2 Answers2

3

In '@angular/core' with @ means taking things from npm

with angular/core is nothing but the folder/path.

In angular '@angular/core' provides list of packages. when you write

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

It gives you a way to make use of component which includes template(html view), class(where logics implemented), and decorators(metadata from angular)

when you write

import { Component,Input } from '@angular/core';

then you will be able to use Input properties which is used to pass data from the container component(parent) to nested component(child)

when you write

import { Component,Output } from '@angular/core';

hen you will be able to use Output properties which is used to pass data from the nested component to Container component.

and this kind of many more things....(refer angular documentation) are there which is possible only when imported from '@angular/core'.

Sunny
  • 577
  • 6
  • 20
2

The @ is a npm feature that allows modules scoping. This means that the core module is part of the angular namespace.

Antoine Boisier-Michaud
  • 1,575
  • 2
  • 16
  • 30