1

私はとても混乱しています。あなたが私を助けてくれることを願っています。

ここは私の工場です

productsFactory.getAllDiciplines = function(){
  return $resource('/api/disciplines/');
}

配列を返します。

これは私のコントローラーです:

$scope.diciplines = ProductsFactory.getAllDiciplines().query();

これは私の見解です:

<select ng-model="diciplines" ng-options="d.dp_title for d in diciplines"></select><br>

これは機能します。ただし、選択ボックスでアイテムを選択すると。それは空になります。すべてのアイテムが消えます。これは、$resource が非同期呼び出しを使用していることと関係があることを知っています。

これを修正するにはどうすればよいですか?

4

1 に答える 1

1

選択したアイテムはリスト全体です!

<select ng-model="diciplines" ng-options="d.dp_title for d in diciplines"></select><br>

別のプロパティ SelectedDicipline を作成し、それをバインドします

$scope.SelectedDicipline  = {};
<select ng-model="SelectedDicipline" ng-options="d.dp_title for d in diciplines"></select><br>
于 2013-09-19T08:25:44.663 に答える