2017-04-16 7 views
0

すべての行の最後の列にボタンが含まれているユーザーの一覧を含む表があります。ボタンをクリックすると、ポップアップフォームが表示されます。ポップアップでは、Angular Chosenの助けを借りて複数選択を使用します。各ユーザーには「興味」のリストがあり、それらを複数の選択肢に表示したいと思います。問題は、必要なすべてのデータをフェッチした後でも、NGモデルが空であるように見えることです。Angular Chosenを使用しているときのng-modelの問題

これは複数選択です。

<select id="multipleSelect" 
        data-placeholder="Select interests..." 
        chosen 
        multiple 
        ng-model="$ctrl.activeInterests" ng-options="interest for interest in $ctrl.interests" 
        style="width:370px; height:100px;"> 
        <option value=""></option> 
</select> 

ここは私のコンポーネントです。この機能は、ボタンをクリックするとトリガされます。 fetchInterestsを呼び出した後

this.editButtonClicked = function(tableRowUser) { 
       $scope.firstName = tableRowUser.firstName; 
       $scope.lastName = tableRowUser.lastName; 
       $scope.email = tableRowUser.email; 
       $scope.role = tableRowUser.role; 
       $scope.tag = tableRowUser.tag; 
       $scope.username = tableRowUser.username; 

       // Fetch the active interests 
       fetchInterests($scope.tag); 
       // Fetch the available interests the user can choose 
       fetchAllAvailableInterests(); 
       // After this, make the Edit Form/Popup visible 
       togglePopupClass(); 
      } 

function fetchInterests(newInterests) { 
       self.activeInterests = []; 
       var interests = newInterests.split('|'); 

       console.log("New interests"); 
       console.log(newInterests); 

       for (i = 0; i < interests.length; i++) { 
        // Trim the excess whitespace. 
        interests[i] = interests[i].replace(/^\s*/, "").replace(/\s*$/, ""); 

        self.activeInterests.push(interests[i]); 
       } 

      } 

は、「activeInterests」私は表示するには、NG-モデルをご希望のものを含みますが、ビューは空のまま。

ご協力いただければ幸いです。

答えて

0

溶液を見出した。 ng-modelに表示したいものは、常にng-optionsにも指定する必要があります。

関連する問題