二级联动angularjs
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
//json 数据
$scope.payWayList = [
{
"amode":"按月",
"gnum":[
{
"payTime":"购置月末",
"price":"0"
}
]
},
{
"amode":"按年",
"gnum":[
{
"payTime":"1年",
"price":"10"
}
]
},
{
"amode":"按需",
"gnum":[
{
"payTime":"1小时",
"price":"0.00138889"
}
]
}
];
$scope.gnumList = "";
//父级绑定事件改变seelct2的值
$scope.payWayCHange = function(select1){
$scope.select2 = $scope.select1.gnum[0];
};
});
<select ng-init="select1=payWayList[0]" ng-model="select1" ng-change="payWayCHange()" ng-options="item.amode for item in payWayList">
</select>
<select ng-init="select2=select1.gnum[0]" ng-model="select2" ng-options="data.payTime for data in select1.gnum">
</select>