Hello,

I'm working through a small script and for some reason I'm getting 
duplicate output and not sure where its coming from..

userloginComponent is the only component calling the html script you see 
below.
Assuming it has something to do with the area I highlighted in red but cant 
seem to see the logic..

See screenshot of output.

user-login.component.ts

export class UserLoginComponent implements OnInit {   
    private userFound: UserType[];
    private errMsg1; 
    testingE = '';
    private testUser = {userName : 'anna'};   

    constructor(private  _findUser: FindUserService, private _router: 
Router) {}

    userLoginButtonMethod(){      
        this._findUser.findUserMethod(this.testUser.userName)
            .subscribe(                
                userData => { 
                    if(userData.length === 0) {                        
                        this.errMsg1 = 'User not found!!';
                        return false;
                    } //end of if statement
                    else {
                        this.userFound = <any>userData[0]; 
                        return true;
                    }// end of else statement
                },
                (error) => { this.testingE = `internal error ${error}`},   
             
                ()=>console.log('finished')
            );
    }

    ngOnInit(){        
        this.userLoginButtonMethod();       
    }
}

the html which displays the results
<h2>Testing</h2>            
        {{ this.userFound.userName }}              
        <pre> {{ this.userFound | json }} </pre>
  
    <div *ngIf="this.errMsg1">Unable to locate user!!!</div>



-- 
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