スコープ ($scope.makes) 内のデータにバインドされた select2 ドロップダウン リストがあります。それは ng-modal 内で「生きています」。
$scope.makes を Promise 内で更新します。これは Parse.com 呼び出し (parse.cloud.run) ですが、その後は DDL が新しいデータで参照されません。しかし、 $scope.$digest() の呼び出しを追加すると、機能します。何故ですか?
これは、モーダル コントローラーの関連部分です。
Parse.Cloud.run('getCarMakes', {}, {
success: function (results) {
console.log('C');
if (results===undefined){
console.log('The query has failed');
return;
}
for (var i=0;i<results.length;i++){
$scope.makes.push(results[i]);
}
$scope.$digest();
最後の行を削除すると、ドロップダウン リストが更新されません。
関連するモーダルのHTML部分は次のとおりです
<label class="control-label" for="MakeSelect">Make </label>
<select class="form-control col-md-2" id="MakeSelect" name="make" ui-select2 ng-model="carDetails.make">
<option ng-repeat="make in makes" value="{{ make }}">{{ make}}</option>
</select>