我做了這樣......從AngularJS控制器我送與先前創建的對象的標識符的請求:
$http({
url: '/api/get/object',
method: "POST",
data: {"id" : $scope.someId}
}).success(function (data) {
$scope.object = angular.fromJson(data);
}).error(function(errorData) { ... });
路線:
POST /api/get/object SomeController.object
在播放動作控制器(我在服務器端使用Play Framework 1.3):
@Transactional
public static void object() {
String id = request.params.get("body").split(":")[1];
SomeObject someObject = SomeObject.findById(Long.parseLong(id));
renderJSON(someObject);
}
我分配標識呃到下拉列表。
<div data-ng-init="initComboBoxes()">
<select id="livingComplexSelectId"
class="form-control m-b"
...
然後,從$scope.object
我提取必要的ID,並通過它們填充選擇。
的AngularJS控制器的有關部分:
$scope.initComboBoxes = function() {
var livingComplexSelector = document.getElementById('livingComplexSelectId');
livingComplexSelector.value = $scope.object.LivingComplexId; // set id
//Loading of dependent values...
// $timeout(function(){$scope.afterWaitInitComboBoxes()}, 5000);
}
謝謝你的回答! –