我正在使用来自https://github.com/angular-ui/ui-select2的 select2
// I have two input select2 box inside one controller
<form ng-controller="MyCtrl">
<input
type="text"
ui-select2="select2Options"
ng-model="bookmarks"
>
<input
type="text"
ui-select2="select2Options"
ng-model="products"
>
</form>
//In controller I have list of bookmarks and products I am trying something like below but it is not working and both the input box ended up with same data i.e. products.
function MyCtrl($scope){
var bookmarks=[
{id:0,text:"enhancement"},
{id:1,text:"bug"},
{id:2,text:"duplicate"},
{id:3,text:"invalid"},
{id:4,text:"wontfix"}
];
$scope.select2Options = {
multiple: true,
width: "300px",
data:bookmarks
};
var products=[
{id:0,text:"Product1"},
{id:1,text:"Product2"},
{id:2,text:"Product3"},
{id:3,text:"Product4"},
{id:4,text:"Product5"}
];
$scope.select2Options = {
multiple: true,
width: "300px",
data:products
};
}
如您所见,上面的代码会将两个输入框转换为 select2 输入框,但两个输入框都将包含产品数据。我想要装满书签的书签输入框和带有产品的产品输入框。