[英]Filling second drop-down multiselect with first drop-down in angularjs
I am new to angular and I am using the angular js-dropdown-multi select module from HERE . 我是angular的新手,正在使用HERE的angular js-dropdown-multi select模块。
I am trying to fill the second drop-down based on first drop-down selection, the first issue I am facing here is when I select single item all are getting selected and second when I try to console the selected one I see [Object object]
, what does that mean? 我正在尝试根据第一个下拉菜单选择填充第二个下拉菜单,这里面临的第一个问题是当我选择单个项目时都被选中,第二个当我尝试对选中的项目进行控制台时,我看到了[Object object]
,那是什么意思?
Any help is much appreciated. 任何帮助深表感谢。
HTML: HTML:
<div ng-dropdown-multiselect=""
options="example14data"
events="eventSettings"
selected-model="example14model"
extra-settings="example14settings">
</div>
<div ng-dropdown-multiselect=""
options="example15data"
selected-model="example15model"
extra-settings="example15settings">
</div>
JavaScript 的JavaScript
var app = angular.module('plunker', ['angularjs-dropdown-multiselect']);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
$scope.example14model = [];
$scope.example14settings = {
scrollable: true,
enableSearch: true,
displayProp: 'type1'
};
$scope.eventSettings={
onItemSelect: function (item) {
console.log('selected: '+item);
}
}
$scope.example14data = [
{
"type1":"A",
"servers":[
{
"type2":"a"
},
{
"type2":"b"
},
{
"type2":"c"
}
]
},
{
"type1":"B",
"servers":[
{
"type2":"d"
},
{
"type2":"e"
},
{
"type2":"f"
}
]
},
{
"type1":"C",
"servers":[
{
"type2":"g"
},
{
"type2":"h"
},
{
"type2":"i"
}
]
},
];
$scope.example15model = [];
$scope.example15settings = {
scrollableHeight: '200px',
scrollable: true,
enableSearch: true,
selectionLimit:1,
displayProp: 'id'
};
$scope.example15data = [];
$scope.example3settings = {
};
});
You need to set the idProp setting so that AngularJS Dropdown Multiselect knows what the unique id of the data is: 您需要设置idProp设置,以便AngularJS Dropdown Multiselect知道数据的唯一ID是什么:
$scope.example14settings = {
scrollable: true,
enableSearch: true,
displayProp: 'type1',
idProp: 'type1',
};
You are concatenating the item variable and a string string which is why you are seeing the [Object object]
您正在串联item变量和字符串字符串,这就是为什么您看到[Object object]
The following code will display the value of item 以下代码将显示item的值
$scope.eventSettings={
onItemSelect: function (item) {
console.log('Selected:');
console.log(item);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.