Skip to content

Commit

Permalink
updating implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
techieshravan committed Jul 23, 2016
1 parent 2408399 commit e6f2f67
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 63 deletions.
3 changes: 0 additions & 3 deletions NotesApp/.bowerrc

This file was deleted.

2 changes: 1 addition & 1 deletion NotesApp/src/components/boot.ts → NotesApp/app/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/platform/browser';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {NotesComponent} from './notes/notes.component';

bootstrap(NotesComponent);
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ <h1>
<div class="container" style="padding:15px">

<div class="input-group">
<input type="text" class="form-control" [(ngModel)]="addNoteText" placeholder="new note" (keypress)="($event.which === 13)?addNote():0" />
<input type="text" class="form-control" [(ngModel)]="addNoteText" placeholder="new note"
(keypress)="($event.which === 13)?addNote():0"/>
<span class="input-group-btn">
<button (click)="addNote()" class="btn btn-success">Add Note</button>
</span>
</div>
<br/>
<div class="panel panel-default" *ngIf="notes.length>0">
<table class="table table-striped">
<tr class="list-group" *ngFor="#note of notes">
<tr class="list-group" *ngFor="let note of notes">
<td>
{{note.noteText}}
<button class="btn btn-xs btn-danger pull-right" ng-click="deleteNote(note)">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
<button class="btn btn-xs btn-danger pull-right" (click)="deleteNote(note)">
<span class="glyphicon glyphicon-remove"></span>
</button>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import {Component} from 'angular2/core';
import {Component} from '@angular/core';
import {Note} from './note'

@Component({
moduleId: module.id,
selector: 'notes-app',
templateUrl: 'src/components/notes/notes.html',
styles:[],
templateUrl: 'notes.component.html',
styles: [],
directives: []
})
export class NotesComponent {

public addNoteText: string;
public notes: Note[] = [];
public addNoteText:string;
public notes:Note[] = [];

addNote(){
addNote() {

if(this.addNoteText) {
if (this.addNoteText) {
var note = new Note();
note.noteText = this.addNoteText;
this.notes.push(note);
Expand All @@ -26,8 +27,7 @@ export class NotesComponent {
}
}

deleteNote(note) {
console.log('deleteNote');
console.log(note);
deleteNote(selectedNote) {
this.notes = this.notes.filter(n => n.noteText !== selectedNote.noteText);
}
}
21 changes: 0 additions & 21 deletions NotesApp/bower.json

This file was deleted.

31 changes: 21 additions & 10 deletions NotesApp/index.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Angular 2 Notes App</title>
<meta charset="UTF-8">
<title>Angular2 Notes App</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap-theme.css">
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>

<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap-theme.css">

<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.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>

<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>

<script>
System.config({
transpiler: 'typescript',
typescriptOptions: { emitDecoratorMetadata: true},
typescriptOptions: {emitDecoratorMetadata: true},
map: {typescript: 'node_modules/typescript/lib/typescript.js'},
packages: {
'src' : {
'src': {
defaultExtension: 'ts'
}
}
});
System.import('src/components/boot').then(null, console.error.bind(console));
</script>
</head>
<body>
<notes-app>Loading...</notes-app>
<notes-app>Loading...</notes-app>
</body>

</html>
26 changes: 17 additions & 9 deletions NotesApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,30 @@
},
"license": "ISC",
"dependencies": {
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/common": "2.0.0-rc.4",
"@angular/compiler": "2.0.0-rc.4",
"@angular/core": "2.0.0-rc.4",
"@angular/forms": "0.2.0",
"@angular/http": "2.0.0-rc.4",
"@angular/platform-browser": "2.0.0-rc.4",
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
"@angular/router": "3.0.0-beta.1",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.4",

"systemjs": "0.19.27",
"es6-shim": "^0.35.0",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12"
"zone.js": "^0.6.12",

"angular2-in-memory-web-api": "0.0.14",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"concurrently": "^2.0.0",
"concurrently": "^2.0.0",
"lite-server": "^2.2.0",
"typescript": "^1.8.10",
"typings":"^0.8.1"
"typings": "^1.0.4"
}
}
54 changes: 54 additions & 0 deletions NotesApp/systemjs.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
(function (global) {

// map tells the System loader where to look for things
var map = {
'app': 'app', // 'dist',
'@angular': 'node_modules/@angular',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'rxjs': 'node_modules/rxjs'
};

// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': {main: 'main.js', defaultExtension: 'js'},
'rxjs': {defaultExtension: 'js'},
'angular2-in-memory-web-api': {main: 'index.js', defaultExtension: 'js'}
};

var ngPackageNames = [
'common',
'compiler',
'core',
'forms',
'http',
'platform-browser',
'platform-browser-dynamic',
'router',
'router-deprecated',
'upgrade'
];

// Individual files (~300 requests):
function packIndex(pkgName) {
packages['@angular/' + pkgName] = {main: 'index.js', defaultExtension: 'js'};
}

// Bundled (~40 requests):
function packUmd(pkgName) {
packages['@angular/' + pkgName] = {main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js'};
}

// Most environments should use UMD; some (Karma) need the individual index files
var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;

// Add package entries for angular packages
ngPackageNames.forEach(setPackageConfig);

var config = {
map: map,
packages: packages
};

System.config(config);

})(this);
7 changes: 2 additions & 5 deletions NotesApp/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"compilerOptions": {
"target": "es5",
"module": "system",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules"
]
}
}
7 changes: 7 additions & 0 deletions NotesApp/typings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160602141332",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"node": "registry:dt/node#6.0.0+20160621231320"
}
}

0 comments on commit e6f2f67

Please sign in to comment.