starting state
This commit is contained in:
parent
cec00f891c
commit
56533dfb39
@ -1 +1 @@
|
||||
<router-outlet></router-outlet>
|
||||
Hello Angular 2+
|
@ -4,19 +4,11 @@ import { HttpModule } from '@angular/http';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import { AppComponent } from './app.cmp';
|
||||
import { RouterModule } from "@angular/router";
|
||||
import { routes } from "./routes";
|
||||
import { ListComponent } from "./list/list.cmp";
|
||||
import { ViewComponent } from "./view/view.cmp";
|
||||
import { TaskService } from "./task.srv";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
HttpModule, FormsModule,
|
||||
RouterModule.forRoot(routes, { useHash: true }) ],
|
||||
declarations: [ AppComponent, ListComponent, ViewComponent ],
|
||||
providers: [ TaskService ],
|
||||
imports: [ BrowserModule, HttpModule, FormsModule],
|
||||
declarations: [ AppComponent ],
|
||||
providers: [],
|
||||
bootstrap: [ AppComponent ]
|
||||
})
|
||||
export class AppModule { }
|
@ -1,26 +1,21 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router'
|
||||
|
||||
import { Task, TaskService } from '../task.srv';
|
||||
import { TaskService } from '../task.srv';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'app/view/view.html'
|
||||
})
|
||||
export class ViewComponent implements OnInit {
|
||||
|
||||
task: Task;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private taskService: TaskService) {}
|
||||
|
||||
back() {
|
||||
this.router.navigateByUrl('/list');
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
const id = parseInt(this.route.snapshot.paramMap.get('id'));
|
||||
this.taskService.getTask(id).then(task => this.task = task);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
Title: {{ task?.title }}<br>
|
||||
Added: {{ task?.added | date: 'dd-MM-yyyy hh:mm' }}<br><br>
|
||||
Title: {{ }}<br>
|
||||
Added: {{ }}<br><br>
|
||||
|
||||
<button (click)="back()">Back</button>
|
||||
|
Loading…
Reference in New Issue
Block a user