Javascript AngularJS表单:根据以前的输入获取第二个选择框的项目
这里的PHP家伙,正在尝试使用AngularJS构建自动更新表单 我的表单如下所示:Javascript AngularJS表单:根据以前的输入获取第二个选择框的项目,javascript,angularjs,forms,Javascript,Angularjs,Forms,这里的PHP家伙,正在尝试使用AngularJS构建自动更新表单 我的表单如下所示: <div ng-app="myapp"> <div ng-controller="ctrl"> Select Road Name: <select ng-model="roadname" ng-options="x for x in roadNames" name="forms_roadName"></select> Select Bus Stop N
<div ng-app="myapp">
<div ng-controller="ctrl">
Select Road Name: <select ng-model="roadname" ng-options="x for x in roadNames" name="forms_roadName"></select>
Select Bus Stop Name: <select ng-model="busstopname" ng-options="x for x in busStopNames" name="forms_BusStopName"></select>
</div>
我希望公共汽车站名称选择框根据所选道路名称自动更新。它没有发生。Chrome控制台不会抛出任何错误,从不满足“if”条件,并且始终执行“else”块。我做错了什么?使用ng change
<select ng-change="updateRoad()" ng-model="roadname" ng-options="x for x in roadNames" name="forms_roadName"></select>
<select ng-change="updateRoad()" ng-model="roadname" ng-options="x for x in roadNames" name="forms_roadName"></select>
app.controller('ctrl', function($scope) {
$scope.roadNames = function_getRoadNames();
if ($scope.roadname !== null) {
$scope.busstopname = function_getBusStopNames($scope.roadname);
} else { $scope.busstopname = ["Select Roadname first"]; }
$scope.updateRoad = function() {
$scope.busstopname = function_getBusStopNames($scope.roadname);
}
});