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 { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { AppComponent } from './app.cmp';
|
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({
|
@NgModule({
|
||||||
imports: [
|
imports: [ BrowserModule, HttpModule, FormsModule],
|
||||||
BrowserModule,
|
declarations: [ AppComponent ],
|
||||||
HttpModule, FormsModule,
|
providers: [],
|
||||||
RouterModule.forRoot(routes, { useHash: true }) ],
|
|
||||||
declarations: [ AppComponent, ListComponent, ViewComponent ],
|
|
||||||
providers: [ TaskService ],
|
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [ AppComponent ]
|
||||||
})
|
})
|
||||||
export class AppModule { }
|
export class AppModule { }
|
@ -1,26 +1,21 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router'
|
import { ActivatedRoute, Router } from '@angular/router'
|
||||||
|
|
||||||
import { Task, TaskService } from '../task.srv';
|
import { TaskService } from '../task.srv';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'app/view/view.html'
|
templateUrl: 'app/view/view.html'
|
||||||
})
|
})
|
||||||
export class ViewComponent implements OnInit {
|
export class ViewComponent implements OnInit {
|
||||||
|
|
||||||
task: Task;
|
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private taskService: TaskService) {}
|
private taskService: TaskService) {}
|
||||||
|
|
||||||
back() {
|
back() {
|
||||||
this.router.navigateByUrl('/list');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
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>
|
Title: {{ }}<br>
|
||||||
Added: {{ task?.added | date: 'dd-MM-yyyy hh:mm' }}<br><br>
|
Added: {{ }}<br><br>
|
||||||
|
|
||||||
<button (click)="back()">Back</button>
|
<button (click)="back()">Back</button>
|
||||||
|
Loading…
Reference in New Issue
Block a user