Y must pass a list of data to a dialog to fill a combobox. In other part of the code I passed a string to dialogs, but, using the same method for this case, It didn´t work.
Here is my js code:
$scope.addPartido = function () {
if ($scope.dataProv.locationsProv.provincias) {
$modal.open({
templateUrl: '../../secure/addPartido/addPartidoDialog.html',
controller: function ($scope, $modalInstance) {
$scope.close = function () {
$modalInstance.close();
};
}
});
}
};
Inside my controler I have the variable $scope.dataProv.locationsProv.provincias fill with de data.
And here is my html code:
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<label>Provincia<span class="text-danger">*</span></label>
<div class="dropdown">
<select ng-options="item.name for item in dataProv.locationsProv.provincias| orderBy:'name'"
ng-id="mySelProvincia" class="form-control" required="required"
ng-model="selectedProv">
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="close()">
Cerrar
</button>
</div>
</div>
</div>
It is easy!
This code works perfectly:
$scope.addPartido = function () {
if ($scope.dataProv.locationsProv.provincias) {
$modal.open({
templateUrl: '../../secure/addPartido/addPartidoDialog.html',
controller: function ($scope, $modalInstance, listProv) {
$scope.statusProv = 'loading...';
$scope.provincia = "Select provincias";
$scope.dataProv = {
"locationsProv": {}
};
$scope.dataProv.locationsProv.provincias = listProv;
$scope.close = function () {
$modalInstance.close();
};
},
resolve: {
listProv: function () {
return $scope.dataProv.locationsProv.provincias;
}
}
});
}
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.