Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 dependencies

Please consider this dependencies in package.json:

"dependencies": {
                  "@angular/common": "2.2.1",
                  "@angular/compiler": "2.2.1",
                  "@angular/core": "2.2.1",
                  "@angular/forms": "2.2.1",
                  "@angular/http": "2.2.1",
                  "@angular/platform-browser": "2.2.1",
                  "@angular/platform-browser-dynamic": "2.2.1",
                  "@angular/router": "3.2.1",
                  "@angular/upgrade": "2.2.1"
                }

I want to use the bundle version of Angulajs and when I run this command:

npm install angular

It installs angular.min.js I want to know what is the difference between Those? Is there any way to bundle dependencies using npm and create a single file?

Another question is I know that Angular 4 has been released and when I run this command:

npm install angular

It installs angular.min.js with version v1.6.4 so what is this file? And why it outdated?

like image 679
Arian Avatar asked Jun 29 '17 06:06

Arian


People also ask

What are the dependencies in Angular?

Types of Dependency Injection in Angular There are three types of Dependency Injections in Angular, they are as follows: Constructor injection: Here, it provides the dependencies through a class constructor. Setter injection: The client uses a setter method into which the injector injects the dependency.

What is @injectable in Angular?

@Injectable() lets Angular know that a class can be used with the dependency injector. @Injectable() is not strictly required if the class has other Angular decorators on it or does not have any dependencies.


1 Answers

When you run npm install angular, AngularJS (v1.x) is installed.
Which is why, when you run the command, the latest stable version of AngularJS i.e v1.6.4 is installed.
Note: Angular v1 (AngularJS) is still supported. Last stable release was 3 months ago.



Angular 2 and above versions are simply called Angular.
Note: Angular(v2 or v4) is an incompatible rewrite of AngularJS(v1)


Now the question is you should choose either of the above according to requirements. The steps you have followed is to get AngularJS(v1).
You can have a look at Angular Quickstart to get started with Angular2+ which is now updated to v4.4.5 (as of 5th July 2017).
You can have a look at Package.json and you would notice,
"dependencies": {
  "@angular/common": "~4.0.0",
  "@angular/compiler": "~4.0.0",
  "@angular/core": "~4.0.0",
  "@angular/forms": "~4.0.0",
  "@angular/http": "~4.0.0",
  "@angular/platform-browser": "~4.0.0",
  "@angular/platform-browser-dynamic": "~4.0.0",
  "@angular/router": "~4.0.0",

  "angular-in-memory-web-api": "~0.3.0",
  "systemjs": "0.19.40",
  "core-js": "^2.4.1",
  "rxjs": "5.0.1",
  "zone.js": "^0.8.4"

},
which should install current stable version of Angular


angular-cli (command-line tool by Angular)
like image 124
Manubhargav Avatar answered Sep 23 '22 15:09

Manubhargav