launchdarkly-labs / ld-tour-of-heroes

LaunchDarkly example app in Angular (versions >=2)
Apache License 2.0
5 stars 5 forks source link

client.identity() is not triggering ui change #3

Open krishnasingh1818 opened 6 years ago

krishnasingh1818 commented 6 years ago

hi, i downloaded sample and tried to run as instructed but am not able to see delete button or search box when change user to admin or internal. below call to change identity is firing but then on event not firing and am not able to see delete buttons. please advise.

 changeUser(user) {
    if (user !== 'Anonymous') {
      this.ldClient.identify({ key: user, name: user, anonymous: false }, null, function(){console.log('changed user != anno'); });
    } else {
      this.ldClient.identify({ key: 'anon', anonymous: true }, null, function(){console.log('changed user == anon '); });
    }
  }
krishnasingh1818 commented 6 years ago

looks like each component was getting new copy of launchdarkly service instance due to explicit use of providers tag at component level. After i commented it out it works fine.

@Component({
  moduleId: module.id,
  selector: 'my-heroes',
  templateUrl: './heroes.component.html',
  styleUrls: ['./heroes.component.css']
  // providers: [LaunchDarklyService]   //remove this line
})