I'm working with a table that lists users, each row ending with a button that triggers a popup form. Inside the popup, I'm using a multiple select feature with Angular Chosen to display each user's 'interests'. However, despite fetching all the necessary data, the ng-model appears to be empty.
Below is the code for the multiple select:
<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>
Here is the component where the function is triggered upon clicking the button:
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();
// 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]);
}
}
Despite successfully populating 'activeInterests' after calling fetchInterests, the ng-model remains empty in the view.
If you have any insights or solutions, your assistance would be greatly appreciated.