อันนี้เป็นโค้ดฝั่ง html ที่ให้ระบุเงื่อนไข
โค้ด: เลือกทั้งหมด
<ion-view view-title="เลือกยี่ห้อ">
<ion-content class="padding">
<form ng-submit="viewGarage()" ng-controller="DataCtrl">
<ul class="list">
<li class="list">
<label class = "item item-input item-select" >
<div class = "input-label">
เลือกยี่ห้อรถ
</div>
<select ng-model="garageData.brand">
<option ng-repeat="b in showBrands" value="{{b.id_b}}">{{b.name_b}}</option>
</select>
<!--<input type="text" ng-model="garageData.brand">-->
</label>
</li>
<li class="list">
<button class="button button-block button-positive" type="submit" >ค้นหา</button>
</li>
</ul>
</form>
</ion-content>
</ion-view>
โค้ด: เลือกทั้งหมด
angular.module('starter.controlManageData', [])
.controller('DataCtrl', function($scope, $ionicModal, $timeout, $ionicPopup, $http, $state, $ionicHistory, $stateParams) {
//path connect file php
var url='...';
$http.get(url+"brand-show.php").success(function(response){
$scope.showBrands=response.records;
}).error(function () {
$ionicPopup.alert({
title:'ข้อมูลอู่ซ่อมรถ',
template:'ไม่สามารถทำการติดต่อเซิร์ฟเวอร์ได้'
});
});
$scope.garageData={};
$scope.viewGarage = function(){
var brand = $scope.garageData.brand;
//alert(brand);
if(brand){
$http.get(url+"detailGarage-show.php?brand="+brand).success(function(response){
$scope.showDetail=response.records;
$state.go('app.detailGarage',[],{location:"replace",reload:true});
}).error(function () {
$ionicPopup.alert({
title:'ข้อมูลอู่ซ่อมรถ',
template:'ไม่สามารถทำการติดต่อเซิร์ฟเวอร์ได้'
});
});
}
};
/*end contrller*/
})
โค้ด: เลือกทั้งหมด
<ion-view view-title="ข้อมูลอู่ซ่อมรถ">
<ion-content class="padding">
<div class="card" ng-controller="DataCtrl" ng-repeat="detail in showDetail">
<input type="hidden" ng-model="garageData.brand">
<div class="item item-text-wrap">
<div class = "input-label">
ชื่อ : {{detail.name_garage}}
</div>
<div class = "input-label">
ยี่ห้อ : {{detail.brand}}
</div>
</div>
</div>
</ion-content>
</ion-view>