blob: 7a4f44b4ebb95fad148e747c39da81366b52f22a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Laptop } from '../models/laptop';
import { LibraryServiceService } from '../services/library.service';
@Component({
selector: 'app-izmeni-laptop',
templateUrl: './izmeni-laptop.component.html',
styleUrls: ['./izmeni-laptop.component.css']
})
export class IzmeniLaptopComponent implements OnInit {
laptop?:Laptop
izmenio?:boolean
constructor(private router:Router,private library:LibraryServiceService, private route:ActivatedRoute) { }
ngOnInit(): void {
this.route.params.subscribe(url=>{
this.library.dajLaptop(url["id"]).subscribe(laptop =>{
this.laptop = laptop
})
})
}
izmeni(laptop?:Laptop)
{
this.library.izmeniLaptop(laptop).subscribe(laptop=>{
this.route.params.subscribe(url=>{
this.library.dajLaptop(url["id"]).subscribe(laptop =>{
this.laptop = laptop
this.izmenio = true;
})
})
})
}
back()
{
this.router.navigate(["/homepage"])
}
}
|