私はこのコンポーネントを使用しようとしています https://github.com/alexklibisz/angular-dual-multiselect-directive しかし、どのようにバックエンドからコンポーネントにデータを渡すことができるのか分かりません。別の変数の変数を角度で使用しますか?
Iは、バックエンドからデータを取得:
var vm = this;
vm.Categoria1 = [];
$http.get('http://localhost:5541/api/date/ListCategorii').success(function (data) {
vm.Categoria1 = data;
}
);
私は、データを取得する:
[{"Id":1,"NumeCategorie":"Fructe"},{"Id":2,"NumeCategorie":"Legume"},{"Id":3,"NumeCategorie":"Ciocolata"}]
しかしvm.Categoria1が空である以下:
$scope.demoOptions = {
title: 'Demo: Recent World Cup Winners',
filterPlaceHolder: 'Start typing to filter the lists below.',
labelAll: 'All Items',
labelSelected: 'Selected Items',
helpMessage: ' Click items to transfer them between fields.',
/* angular will use this to filter your lists */
orderProperty: 'name',
/* this contains the initial list of all items (i.e. the left side) */
items: vm.Categoria1, //[{ 'id': '50', 'name': 'Germany' }, { 'id': '45', 'name': 'Spain' }, { 'id': '66', 'name': 'Italy' }, { 'id': '30', 'name': 'Brazil' }, { 'id': '41', 'name': 'France' }, { 'id': '34', 'name': 'Argentina' }],
/* this list should be initialized as empty or with any pre-selected items */
selectedItems: []
};
ありがとうございました。
、あなたはすでにvm.Categoria1セットを持っていますか? $ http呼び出しは非同期であるため、demoOptionsオブジェクトを初期化した後にのみ結果を受け取ることができます。 –