2016-04-06 8 views
0

私はこのテーブルをユーザがクリックしたチェックボックスの表示要素にします。しかし、ユーザーがチェックボックスをクリックすると、何も表示されなくなります。テーブルの表示チェックボックスの入力にエラーがあります

<td ng-switch="user.scope"> 
    <span class="label label-primary" ng-switch-when="1">Admin</span> 
    <span class="label label-primary" ng-switch-when="2">App</span> 
    <span class="label label-primary" ng-switch-when="3">Redemption</span> 
</td> 

これは私のモーダルフォームのチェックボックス要素です。

<label for="scope">Scope</label><br> 
    <input type="checkbox" ng-model="user.scope.admin" name="scope[]" value="1"> Admin <br> 
    <input type="checkbox" ng-model="user.scope.app" name="scope[]" value="2"> App <br> 
    <input type="checkbox" ng-model="user.scope.redemption" name="scope[]" value="3"> Redemption <br> 

これはjavascriptの部分です。それだけで一つの式の値に依存しているので、あなたがng-switchを使用することはできません複数選択の場合

$scope.users = [{username: "a", name:"b", password:"c", confirmpassword:"d", status:"0", scope:"1" }]; 

    $scope.addUser = function(user) { 
     $dialog.open({ 
      showClose: false, 
      closeByEscape: true, 
      template: 'views/user/user-user-add.html', 
      controller: ['$scope', function ($dialogScope) { 
       $dialogScope.isLoading =false; 
       $dialogScope.title = "New User"; 
       $dialogScope.user = { 
        username : "" , 
        name : "", 
        password :"", 
        confirmpassword :"", 
        status : "", 
        scope : {}, 
       }; 

$dialogScope.add = function() { 
        console.log($dialogScope.user); 
        $scope.users.push($dialogScope.user); 
        $dialogScope.closeThisDialog(); 
       } 
+0

は、あなたがオブジェクト –

+0

としてそれを持って、これはコントローラからですが、それはしないでください@ArunPJohnyのスコープに表示する : オブジェクト scope3 : true – sue

答えて

0

、あなたはそれぞれの式をチェックする必要があり、user.scope.adminなどと使用NG-ショー。

例:あなたは、1,2または3のいずれかとしuser.scope` `の値を設定する必要が

<td> 
    <span class="label label-primary" ng-show="user.scope.admin">Admin</span> 
    <span class="label label-primary" ng-show="user.scope.app">App</span> 
    <span class="label label-primary" ng-show="user.scope.redemption">Redemption</span> 
</td> 
+0

は私にエラーを返します。チェックボックスは選択できません。自動的にすべてをクリックします – sue

+0

1つだけを選択する必要がありますか?複数の? – war1oc

+0

複数選択が必要 – sue

関連する問題