Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@angular/platform-browser": "~4.3.4",
"@angular/platform-browser-dynamic": "~4.3.4",
"@angular/router": "~4.3.4",

"angular-in-memory-web-api": "~0.3.0",
"systemjs": "0.19.40",
"core-js": "^2.4.1",
Expand All @@ -43,7 +42,6 @@
"concurrently": "^3.2.0",
"lite-server": "^2.2.2",
"typescript": "~2.1.0",

"canonical-path": "0.0.2",
"tslint": "^3.15.1",
"lodash": "^4.16.4",
Expand All @@ -55,7 +53,6 @@
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",

"@types/node": "^6.0.46",
"@types/jasmine": "2.5.36"
},
Expand Down
2 changes: 1 addition & 1 deletion protractor.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.config = {
useAllAngular2AppRoots: true,

// Base URL for application server
baseUrl: 'http://localhost:8080',
baseUrl: 'http://localhost:3000',

// doesn't seem to work.
// resultJsonOutputFile: "foo.json",
Expand Down
22 changes: 20 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
import { Component } from '@angular/core';
import { Todo } from './todo';
import { TodoService } from './todo.service';

@Component({
selector: 'my-app',
template: `<h1>Hello {{name}}</h1>`,
template: `<h1>NodeTodo</h1>
<ul>
<li *ngFor="let todo of todos">
{{todo.todo}} - {{todo.isDone}}
</li>
</ul>`,
providers: [TodoService]
})
export class AppComponent { name = 'Angular'; }

export class AppComponent {
todos: Todo[];
constructor(private todoService: TodoService) {}
getTodos(): void {
this.todoService.getTodos().then(todos => this.todos = todos);
}
ngOnInit(): void {
this.getTodos();
}
}
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';

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

//Decorator
@NgModule({
imports: [ BrowserModule ],
imports: [ BrowserModule, HttpModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
Expand Down
20 changes: 20 additions & 0 deletions src/app/todo.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Injectable } from '@angular/core';
import { Headers, Http } from '@angular/http';

import 'rxjs/add/operator/toPromise';

import { Todo } from './todo';

@Injectable()
export class TodoService {
private headers = new Headers({'Content-Type': 'application/json'});
private todosApiUrl = 'api/todos/test';

constructor(private http:Http) {}

getTodos(): Promise<Todo[]> {
return this.http.get(this.todosApiUrl)
.toPromise()
.then(response => response.json() as Todo[])
}
}
6 changes: 6 additions & 0 deletions src/app/todo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class Todo {
_id: string;
todo: string;
isDone: boolean;
hasAttachment: boolean;
}
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Angular QuickStart</title>
<title>Node Todo</title>
<base href="/">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand Down
1 change: 1 addition & 0 deletions src/systemjs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js',
meta: {
'./*.js': {
Expand Down