【发布时间】:2015-11-03 14:06:57
【问题描述】:
我的数据库中有 2 个表,名为:transporteur 和 camion,每个 transporteur 都有许多 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('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;
});
}])
我想根据选择的codeTransporteur显示camion数据。
【问题讨论】:
-
你能告诉我
$scope.camion和$scope.transporteur的示例输出吗? -
应用程序的输出??! @mhx
-
是的,请求在其成功函数中返回什么? (data.camion & data.transporteur)
-
它返回所有数据(camions 和 transporteurs).. 从 db @mhx 选择所有数据时没有错误
标签: angularjs select filter ionic-framework ionic