I have 2 tables in my database named : transporteur and camion , each transporteur has many camions :
CREATE TABLE IF NOT EXISTS `camion` (
`id` int(11) NOT NULL,
`matricule` varchar(255) NOT NULL,
`idTransporteur` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `transporteur` (
`id` int(11) NOT NULL,
`codeTransporteur` varchar(255) NOT NULL,
`RS` varchar(255) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
ALTER TABLE `camion`
ADD PRIMARY KEY (`id`), ADD KEY `FK_1` (`idTransporteur`);
HTML:
<label class="item item-input item-select">
<div class="input-label">transporteur</div>
<select ng-model="transp">
<option ng-repeat="x in transporteur">{{x[1]}}</option>
</select>
</label>
<label class="item item-input item-select">
<div class="input-label">matricule camion</div>
<select ng-model="matriculeCamion" >
<option ng-repeat="x in camion">{{x[1]}}</option>
</select>
</label>
Controller:
.controller('AddController',['$scope','$http','$state',function($scope,$http,$state){
var request = $http({
method: "post",
url: "http://localhost:8180/ExtractDataSelect.php",
headers: { 'Content-Type': undefined }
});
request.success(function(data,status,headers,config) {
$scope.camion=data.camion;
$scope.transporteur=data.transporteur;
});
}])
I want to show the camion data based on the selected codeTransporteur.