4

I am new to angular 2 and following the angular 2 quick start guide. I am trying to understand the directory structure of angular app . I am using npm to build the app . I came across the import statements in angular 2

e.g.

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

I found it sytemjs.config.js file that mapped like

'@angular/core': 'npm:@angular/core/bundles/core.umd.js'

where

'npm:': 'node_modules/'

npm: is alias for node_module folder.

But when I am using my custom component(made by user) and imports this like

import {AppComponent} from './app.component';

what the dot(.) represent here ,is it representing the app folder mapped as

app: 'app',
nem035
  • 34,790
  • 6
  • 87
  • 99
optional
  • 3,260
  • 5
  • 26
  • 47

1 Answers1

12

The dot has nothing to do with angular, it just means the current directory.

For example, if you have two files like this

app
  file1.js
  file2.js

And then inside app/file1.js:

import './file2'

This will tell your module loader to look for file2.js in the app directory because that is the current directory of file1.js.

You can also use .. to look into the parent directory.

Here's a good explanation from the dot definition, obtained from Rahul Tripathi:

On Unix-like operating systems every directory contains, as a minimum, an object represented by a single dot and another represented by two successive dots. The former refers to the directory itself and the latter refers to its parent directory (i.e., the directory that contains it). These items are automatically created in every directory, as can be seen by using the ls command with its -a option (which instructs it to show all of its contents, including hidden items).

Community
  • 1
  • 1
nem035
  • 34,790
  • 6
  • 87
  • 99