Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit } from '@angular/core';
- import { ActivatedRoute, Params } from '@angular/router';
- import { User } from '../shared/index';
- import {UserService} from '../../../_services/index';
- import { Response } from '@angular/http';
- import { Observable } from 'rxjs';
- @Component({
- moduleId: module.id,
- templateUrl: 'edit.component.html',
- providers: [UserService]
- })
- export class UserEditComponent implements OnInit {
- public user:User[];
- constructor(
- private route:ActivatedRoute,
- private http:UserService) {
- }
- ngOnInit() {
- this.route.params.subscribe(params => {
- this.search(+params['id']);
- //return this.http.getUser(+params['id'])
- // .subscribe((data)=> { this.user = data; });
- });
- }
- search(id: number): Observable<User[]> {
- return this.http
- .getUser(id)
- .map((r: Response) => r.json().data as User[]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement