Javascript 使用上一个“在ng中选择”选项中的值
我有以下代码:Javascript 使用上一个“在ng中选择”选项中的值,javascript,angularjs,Javascript,Angularjs,我有以下代码: <label class="item item-input item-select" name="coffeehouse"> <span class="input-label">Coffee House</span> <select ng-options="shop.label for shop in products" ng-model="order.coffeehouse"></select> </la
<label class="item item-input item-select" name="coffeehouse">
<span class="input-label">Coffee House</span>
<select ng-options="shop.label for shop in products" ng-model="order.coffeehouse"></select>
</label>
<label class="item item-input item-select" name="product">
<span class="input-label">Product</span>
<select ng-options="product.label for product in //PROBLEM//" ng-model="order.product"></select>
</label>
请注意,它使用工厂,因此您在这里看不到数据源,但它是一个对象数组,如下所示:
[
{ label: 'Store 1', products: [{ label: 'Product 1' }, { label: 'Product 2' }] },
{ label: 'Store 2', products: [{ label: 'Product 1' }, { label: 'Product 2' }] }
]
有什么想法吗?这里有一种方法:
var myApp=angular.module('myApp',['ionic']);
myApp.controller('DropCtrl',函数($scope,$ionicLoading){
$ionicLoading.show({
模板:“正在加载…”,
动画:“淡入”,
真的,,
放映延迟:10
});
$scope.order={};
$scope.products=[
{label:'Store 1',products:[{label:'Product 1'},{label:'Product 2'}]},
{label:'Store 2',products:[{label:'Product 1'},{label:'Product 2'}]}
];
//模拟加载1.5秒。
setTimeout(函数(){
$ionicLoading.hide();
}, 1500);
});代码>
咖啡馆
产品
您可以发布控制器吗?
[
{ label: 'Store 1', products: [{ label: 'Product 1' }, { label: 'Product 2' }] },
{ label: 'Store 2', products: [{ label: 'Product 1' }, { label: 'Product 2' }] }
]