2017-02-08 7 views
0

私は自分のプロジェクト用のアプリケーションを作成しています。ユーザー名、電子メール、ロール(ドロップダウン値)の3つのフィールドで構成されたユーザー招待フォームがあります。私のアプリケーションは、ユーザAがロールのドロップダウンで1,2,3,4,5のディスプレイにログインしても、ユーザBが3 4と5だけでログインすると、このようになります。私は、ユーザAの値を取得しています、セッションストレージからユーザBは、ここでは= "の役割をngForましょう* HTMLセッションストレージから取得した値に基づくドロップダウン値の変更

<option [value]="role.id" *ngFor="let role of roles">{{role.roleName}}</option> 
+0

<オプション[値] =「role.id」の現在のロジックですroles "> {{role.roleName}} –

答えて

0
Service will return the role id, each user is assigned a unique role id, first capture the role id and then do the data handling 

     this.inviteService.getRoles().subscribe(data => { 
     this.sessionService.set('roles',data); 
     this.roles =this.sessionService.get<any>('roles'); 
     var rolesList: any=[];`enter code here` 
     if(this.sessionService.getHigherRoleId() == 2) 
//getHigherRoledId is returned from a service, which gives the roleId 
     { 
      this.roles.forEach(singleRole => { 
      if (!((singleRole.id ==1)||(singleRole.id == 3))){ 
       rolesList.push(singleRole); 

      } 
      }); 

      this.roles=[]; 
     this.roles = rolesList; 
     } 
関連する問題