Skip to content

Commit

Permalink
Upgrade the projec to Angular 2 RC1.
Browse files Browse the repository at this point in the history
  • Loading branch information
mosh-hamedani committed May 18, 2016
1 parent f81c7ca commit 331127c
Show file tree
Hide file tree
Showing 18 changed files with 94 additions and 59 deletions.
4 changes: 2 additions & 2 deletions app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component} from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {Component} from '@angular/core';
import {RouteConfig, ROUTER_DIRECTIVES} from '@angular/router-deprecated';

import {NavBarComponent} from './navbar.component';
import {HomeComponent} from './home.component';
Expand Down
6 changes: 3 additions & 3 deletions app/boot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {bootstrap} from 'angular2/platform/browser';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {HTTP_PROVIDERS} from 'angular2/http';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {ROUTER_PROVIDERS} from '@angular/router-deprecated';
import {HTTP_PROVIDERS} from '@angular/http';

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

Expand Down
2 changes: 1 addition & 1 deletion app/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, OnInit} from 'angular2/core';
import {Component, OnInit} from '@angular/core';

@Component({
template: '<h1>Home</h1>'
Expand Down
4 changes: 2 additions & 2 deletions app/navbar.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component} from 'angular2/core';
import {ROUTER_DIRECTIVES, Router} from 'angular2/router';
import {Component} from '@angular/core';
import {ROUTER_DIRECTIVES, Router} from '@angular/router-deprecated';

@Component({
selector: 'navbar',
Expand Down
2 changes: 1 addition & 1 deletion app/not-found.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from 'angular2/core';
import {Component} from '@angular/core';

@Component({
template: `
Expand Down
4 changes: 2 additions & 2 deletions app/posts/post.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Injectable} from 'angular2/core';
import {Http} from 'angular2/http';
import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
Expand Down
6 changes: 3 additions & 3 deletions app/posts/posts.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ <h1>Posts</h1>
<div class="col-md-6">
<select class="form-control" (change)="reloadPosts({ userId: u.value })" #u>
<option value="">Select a user...</option>
<option *ngFor="#user of users" value="{{ user.id }}">
<option *ngFor="let user of users" value="{{ user.id }}">
{{ user.name }}
</option>
</select>
<spinner [visible]="postsLoading"></spinner>
<pagination [items]="posts" (page-changed)="onPageChanged($event)"></pagination>
<ul class="list-group posts">
<li *ngFor="#post of pagedPosts" class="list-group-item" [class.active]="currentPost == post" (click)="select(post)">
<li *ngFor="let post of pagedPosts" class="list-group-item" [class.active]="currentPost == post" (click)="select(post)">
{{ post.title }}
</li>
</ul>
Expand All @@ -24,7 +24,7 @@ <h3 class="panel-title">{{ currentPost.title }}</h3>
<p>{{ currentPost.body }}</p>
<hr/>
<spinner [visible]="commentsLoading"></spinner>
<div class="media" *ngFor="#comment of currentPost.comments">
<div class="media" *ngFor="let comment of currentPost.comments">
<div class="media-left">
<a href="#">
<img class="media-object thumbnail" src="http://lorempixel.com/80/80/people?random={{ comment.id }}" alt="...">
Expand Down
2 changes: 1 addition & 1 deletion app/posts/posts.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, OnInit} from 'angular2/core';
import {Component, OnInit} from '@angular/core';

import {PostService} from './post.service';
import {UserService} from '../users/user.service';
Expand Down
2 changes: 1 addition & 1 deletion app/shared/basicValidators.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Control} from 'angular2/common';
import {Control} from '@angular/common';

export class BasicValidators{
static email(control: Control){
Expand Down
6 changes: 3 additions & 3 deletions app/shared/pagination.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, Input, Output, EventEmitter} from 'angular2/core';
import {OnChanges} from 'angular2/core';
import {Component, Input, Output, EventEmitter} from '@angular/core';
import {OnChanges} from '@angular/core';

@Component({
selector: 'pagination',
Expand All @@ -11,7 +11,7 @@ import {OnChanges} from 'angular2/core';
<span aria-hidden="true">&laquo;</span>
</a>
</li>
<li [class.active]="currentPage == page" *ngFor="#page of pages" (click)="changePage(page)">
<li [class.active]="currentPage == page" *ngFor="let page of pages" (click)="changePage(page)">
<a>{{ page }}</a>
</li>
<li [class.disabled]="currentPage == pages.length">
Expand Down
2 changes: 1 addition & 1 deletion app/shared/spinner.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Input} from 'angular2/core';
import {Component, Input} from '@angular/core';

@Component({
selector: 'spinner',
Expand Down
6 changes: 3 additions & 3 deletions app/users/user-form.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, OnInit} from 'angular2/core';
import {FormBuilder, ControlGroup, Validators} from 'angular2/common';
import {CanDeactivate, Router, RouteParams} from 'angular2/router';
import {Component, OnInit} from '@angular/core';
import {FormBuilder, ControlGroup, Validators} from '@angular/common';
import {CanDeactivate, Router, RouteParams} from '@angular/router-deprecated';

import {BasicValidators} from '../shared/basicValidators';
import {UserService} from './user.service';
Expand Down
4 changes: 2 additions & 2 deletions app/users/user.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Injectable} from 'angular2/core';
import {Http} from 'angular2/http';
import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion app/users/users.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1>Users</h1>
</tr>
</thead>
<tbody>
<tr *ngFor="#user of users">
<tr *ngFor="let user of users">
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
<td>
Expand Down
4 changes: 2 additions & 2 deletions app/users/users.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, OnInit} from 'angular2/core';
import {RouterLink} from 'angular2/router';
import {Component, OnInit} from '@angular/core';
import {RouterLink} from '@angular/router-deprecated';

import {UserService} from './user.service';

Expand Down
22 changes: 6 additions & 16 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,20 @@
<!-- 1. Load libraries -->
<!-- IE required polyfills, in this exact order -->
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>

<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/router.dev.js"></script>
<script src="node_modules/angular2/bundles/http.dev.js"></script>

<script src="node_modules/underscore/underscore.js"></script>

<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/boot')
.then(null, console.error.bind(console));
System.import('app').catch(function(err){ console.error(err); });
</script>


</head>

<!-- 3. Display the application -->
Expand Down
39 changes: 24 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,37 @@
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"postinstall": "npm run typings install",
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"start": "concurrent \"npm run tsc:w\" \"npm run lite\" ",
"typings": "typings"
},
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-beta.6",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"systemjs": "0.19.20",
"underscore": "^1.8.3",
"zone.js": "0.5.14"
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.1",
"@angular/upgrade": "2.0.0-rc.1",
"systemjs": "0.19.27",
"es6-shim": "^0.35.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"angular2-in-memory-web-api": "0.0.7",
"bootstrap": "^3.3.6",
"underscore": "^1.8.3"
},
"devDependencies": {
"concurrently": "^1.0.0",
"lite-server": "^2.0.1",
"typescript": "^1.7.5",
"typings": "^0.6.8"
"concurrently": "^2.0.0",
"lite-server": "^2.2.0",
"typescript": "^1.8.10",
"typings":"^0.8.1"
}
}
36 changes: 36 additions & 0 deletions systemjs.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(function(global) {
// map tells the System loader where to look for things
var map = {
'app': 'app', // 'dist',
'rxjs': 'node_modules/rxjs',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'@angular': 'node_modules/@angular'
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'boot.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { defaultExtension: 'js' },
};
var packageNames = [
'@angular/common',
'@angular/compiler',
'@angular/core',
'@angular/http',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/router',
'@angular/router-deprecated',
'@angular/testing',
'@angular/upgrade',
];
// add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' }
packageNames.forEach(function(pkgName) {
packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
});
var config = {
map: map,
packages: packages
}
System.config(config);
})(this);

1 comment on commit 331127c

@rakeshkumar125
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am new with angular 2. Before current commits working fine. After this commit its not working. It gives below error.

$ npm start

angular2-quickstart@1.0.0 start K:\XAMPP\htdocs\angular2\angular2-course
tsc && concurrently "npm run tsc:w" "npm run lite"

app/posts/posts.component.ts(54,39): error TS2304: Cannot find name ''.
app/posts/posts.component.ts(80,27): error TS2304: Cannot find name '
'.
app/posts/posts.component.ts(80,34): error TS2304: Cannot find name '_'.
app/users/users.component.ts(1,33): error TS2307: Cannot find module '@angular2/core'.
app/users/users.component.ts(2,26): error TS2307: Cannot find module '@angular2/router-deprecated'.
node_modules/angular2/src/facade/promise.d.ts(1,10): error TS2661: Cannot re-export name that is not defined in the module.

npm ERR! Windows_NT 6.1.7600
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start"
npm ERR! node v6.11.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! angular2-quickstart@1.0.0 start: tsc && concurrently "npm run tsc:w" "npm run lite"
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the angular2-quickstart@1.0.0 start script 'tsc && concurrently "npm run tsc:w" "npm run lite" '.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular2-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! tsc && concurrently "npm run tsc:w" "npm run lite"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular2-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls angular2-quickstart
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! K:\XAMPP\htdocs\angular2\angular2-course\npm-debug.log

Any one can help us.

Please sign in to comment.