Javascript 使用角度选择时ng模型的问题
我有一个包含用户列表的表,其中每行的最后一列包含一个按钮。单击按钮时,会出现一个弹出窗体。在弹出窗口中,我在Angular Selected的帮助下使用了多重选择。每个用户都有一个“兴趣”列表,我想在多选框中显示它们。问题是,即使在获取了所有必要的数据之后,ng模型也似乎是空的 这是多重选择Javascript 使用角度选择时ng模型的问题,javascript,angularjs,jquery-chosen,angular-chosen,Javascript,Angularjs,Jquery Chosen,Angular Chosen,我有一个包含用户列表的表,其中每行的最后一列包含一个按钮。单击按钮时,会出现一个弹出窗体。在弹出窗口中,我在Angular Selected的帮助下使用了多重选择。每个用户都有一个“兴趣”列表,我想在多选框中显示它们。问题是,即使在获取了所有必要的数据之后,ng模型也似乎是空的 这是多重选择 <select id="multipleSelect" data-placeholder="Select interests..."
<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>
这是我的组件。单击按钮时会触发此功能
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]);
}
}
this.editButtonClicked=函数(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;
//获取积极的兴趣
获取兴趣($scope.tag);
//获取用户可以选择的可用兴趣
获取所有可用权益();
//之后,使编辑表单/弹出窗口可见
togglePopupClass();
}
职能部门利益(新利益){
self.activeInterests=[];
var利息=新利息。拆分(“|”);
控制台日志(“新权益”);
console.log(newInterests);
for(i=0;i
调用fetchInterests后,“activeInterests”包含我希望ng模型显示的内容,但视图仍然为空
任何帮助都将不胜感激。找到了解决方案。您希望在ng模型中显示的内容也应该始终在ng选项中