(function (app) { app.controller('homeCtrl', ["$scope", 'goodsService', 'carService', 'msg', '$state', '$ionicHistory','config', function ($scope, goodsService, carService, msg, $state, $ionicHistory,config) { $scope.vm = { showIndex: 1 }; $scope.host = config.server +'/upload/photo/'; $scope.changeTab = function (i) { $scope.vm.showIndex = i; } $scope.goods = []; goodsService.listGoods({ type: 1, pageIndex: 1 }).then(function (result) { $scope.goods = result.data.data; }, function (erro) { // msg.error(erro.data.message); }); $scope.cars = []; carService.listCars({ type: 2, pageIndex: 1 }).then(function (result) { $scope.cars = result.data.data; }, function (erro) { // msg.error(erro.data.message); }); $scope.detail = function (item) { if ($scope.vm.showIndex == 1) //货源 { $state.go('wl.goods_detail', {item:item}); } if ($scope.vm.showIndex == 2) //车源 { $state.go('wl.car_detail', { item: item }); } } $scope.go = function (target) { $ionicHistory.clearHistory(); $state.go(target); } }]); })(angular.module('app.controllers'));