2017-03-02 4 views
0

ビューと同じ2つの異なるフォームを使用したいと思います。のロールがあります。私のコントローラで 1.クライアント 2.マネージャーHTML(Angular JS)でフラグのフォームベースを切り替える方法

私がログインしているユーザーの役割に基づいてフラグを追加した。

$scope.userFlag=$rootScope.globalSession.UserRole, 

私はマネージャーとしてログインしている場合、値$ rootScope.globalSession.UserRole = "マネージャー" の

&私はクライアントとしてログインしている場合$ rootScope.globalSession.UserRole =今、 "クライアント"

私の形で、私はそれを切り替えるための条件を追加したの、値 - >NG-IF = "userFlag ==管理"

 <form class="form-horizontal" name="UpdateAdminProfileForm" id="UpdateAdminProfileForm"> 
      <h2>Update Profile</h2> 
       <hr> 
      <fieldset name="client" id="client" ng-if="userFlag==Admin"> 

       <!-- Text input--> 
       <div class="form-group"> 
        <label class="col-md-4 control-label" for="username">Domain Name*</label> 
        <div class="col-md-4"> 
         <input id="username" name="username" type="text" placeholder="Enter your username" class="form-control input-md" ng-model="theClient.OrganizationDomain" disabled> 

        </div> 
       </div> 

       <!-- Button --> 
       <div class="form-group"> 
        <label class="col-md-4 control-label" for="update"></label> 
        <div class="col-md-4"> 
         <a><button id="update" name="update" class="btn btn-primary" ng-click="updateClient()">Update</button></a> 

        </div> 
       </div> 
      </fieldset> 
      <fieldset name="manager" id="manager" ng-show="userFlag==Manager"> 

       <div class="form-group" ng-class="{ 'has-error': submitted && UpdateAdminProfileForm.myemail.$error.required || UpdateAdminProfileForm.myemail.$error.pattern }"> 
        <label class="col-md-4 control-label" for="myemail">Email*</label> 
        <div class="col-md-4"> 
         <input id="myemail" name="myemail" type="email" placeholder="Enter your email" class="form-control input-md" ng-model="theClient.Email" ng-pattern="regex.Email" ng-maxlength="20" required autofocus > 
         <span ng-show="submitted && UpdateAdminProfileForm.myemail.$error.required" class="help-block">Email can not be empty</span> 
         <span ng-show="UpdateAdminProfileForm.myemail.$error.pattern && UpdateAdminProfileForm.myemail.$invalid " class="help-block">Please enter a valid email</span> 
        </div> 
       </div> 

     <div class="modal-footer"> 
    <button class="btn btn-primary" data-dismiss="modal" type="button" ng-click="updateManager()">Save</button> 
    </div> 
      </fieldset> 
     </form> 
    </div> 
</div> 

しかし、私はNG-IF = "userFlag ==管理" & NG-IF = "userFlagを削除した場合、その私は、その空のフォームを開いたときに作業していない==マネージャー"からタグの場合、両方のフィールドセットのフィールドが表示されます。 FLAG

enter image description here

ヘルプを削除した後、FLAG

With Flag

イメージを使用して

画像!前もって感謝します。

答えて

1

それは

ng-if="userFlag=='Admin'" 
1

この

ng-if="userFlag=='Admin'" or ng-show="userFlag=='Manager'" 
を試してみてくださいする必要があります
関連する問題