ngx-academia-uniandes-library
Version:
This library is used for Academia-Uniandes system.
45 lines • 1.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var http_1 = require("@angular/common/http");
var Observable_1 = require("rxjs/Observable");
require("rxjs/add/operator/map");
require("rxjs/add/operator/catch");
var SearchComboBoxGenericService = /** @class */ (function () {
function SearchComboBoxGenericService(http) {
this.http = http;
}
SearchComboBoxGenericService.prototype.getItems = function (searchText, componentModel) {
var params = new http_1.HttpParams();
if (componentModel.queryParams) {
if (searchText) {
params = params.set('query', searchText);
}
;
if (componentModel.queryParams) {
componentModel.queryParams.forEach(function (queryParam) { return params = params.append(queryParam.name, queryParam.value); });
}
;
return this.http.get(componentModel.urlService, { params: params })
.catch(this.handleError);
}
else if (componentModel.body) {
componentModel.body[componentModel.findBy] = searchText;
return this.http.post(componentModel.urlService, componentModel.body)
.catch(this.handleError);
}
};
SearchComboBoxGenericService.prototype.handleError = function (error) {
return Observable_1.Observable.throw(error.statusText || 'Server error');
};
SearchComboBoxGenericService.decorators = [
{ type: core_1.Injectable },
];
/** @nocollapse */
SearchComboBoxGenericService.ctorParameters = function () { return [
{ type: http_1.HttpClient, },
]; };
return SearchComboBoxGenericService;
}());
exports.SearchComboBoxGenericService = SearchComboBoxGenericService;
//# sourceMappingURL=search-combo-box-generic.service.js.map