My object is to query the database (mysl/php) using  *userName* as the 
search criteria (currently hard coded for testing) and have that data 
available to work with for example {{this.foundUsername.userName}}. As of 
now I'm able to query the database and able to display it as 
and the out put is:

but I can't seem to do anything else with the data. Assuming its one big 
string. I used similar steps and received object that I can use with the 
*ngFor directive but in this instance its not array object that I can work 
with, any help you can provide would be greatly appreciated. 

import { Component }       from '@angular/core';
import { PersonType }      from '../services/persontype';

import { FindUserService } from './find-user.service';

*@Component ({*
    selector: 'user-search',
    template: `<h3>{{title}}</h3> 
        <input #inputUsername>
        <button (click)="findUser(inputUsername.value); 
inputUsername.value='' ">Find User</button>
        <br><h2>found(works): {{this.foundUsername}}</h2>   
        *<br><h2>found(not working): 
{{this.foundUsername[0].username}}</h2>      *         
        <div class = "error" *ngIf="errorMessage"> {{errorMessage}}</div>`,
    providers: [ FindUserService ]
//<div *ngFor = "test1 of this.foundUsername">{{test1.userName}}</div>
export class UserSearchComponent{
    title = 'User search';
    private foundUsername: any;
    errorMessage: string;
    constructor(private _findUser: FindUserService ){ }

                  data => this.foundUsername = JSON.stringify(data) ,
                  error => this.errorMessage = <any>error);                 

import { Injectable } from '@angular/core';
import {Headers,  Http, Response, URLSearchParams, RequestOptions } from 
import { Observable }        from 'rxjs/Observable';
import { PersonType } from '../services/persontype'; 

@Injectable( )
export class FindUserService{   
    private _testUser: string = 'Robin';    
    private userUrl = 

    constructor(private http: Http) { }    

    searchForUserMethod(): Observable<PersonType[]> {           

        return this.http
            .get(this.userUrl + '?userName='+ this._testUser )
            .map((response: Response) => <PersonType[]>response.json())

    private handleError(error: any): Promise<any> {
        console.error('An error occurred', error); // for demo purposes only
        return Promise.reject(error.message || error);

     private extractData(res: Response) {
        let body = res.json();
        // return body.data || [];
        return body;       

You received this message because you are subscribed to the Google Groups 
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to