UNPKG

unserver-unify

Version:

56 lines (46 loc) 1.52 kB
'use strict'; angular.module('bamboo.company').controller('CompanySearchCtrl', function($stateParams, ApiService, $scope) { var _self = this; this.q = $stateParams.key; this.page = 1; this.defaultPhoto = "assets/images/company.png"; this.companypath = ApiService.SHOST + '/company/'; this.inspectorFlag = false; var page = 0; var limit = 8; this.items = []; this.pageChanged = function(newPage) { _self.page = newPage; _self.getCompanys(_self.q); }; this.getCompanys = function(q) { var info = { // id: ApiService.gid, action: "getcompanys", // page: page - 1, start: (_self.page -1)* limit, sort: { reverse: true, counter: 'counter' }, limit: limit, search: { searchcompany: q }, }; // console.log(info); console.log(info); ApiService.post("/business", info).then(function(result) { console.log(result.data.data); if (result.data.success) { $scope.searchCount = result.data.data.counter || 0; $scope.searchName = q; _self.items = result.data.data.items; } }); } if (this.q && this.q.length) { console.log("============="); _self.getCompanys(_self.q); } });