Angularjs 如何使用ng选项创建下拉列表
来自REST的JSONAngularjs 如何使用ng选项创建下拉列表,angularjs,ng-options,Angularjs,Ng Options,来自REST的JSON http://localhost:8080/TestServer/webresources/com.rako.rma.product { brandBrandId: { brandId: 2, brandName: "Ticca", isGun: true }, created: "2015-04-09T12:06:37", lotn: "1111", productId: 1 } HTML <select data-ng-model="products.bran
http://localhost:8080/TestServer/webresources/com.rako.rma.product
{
brandBrandId: {
brandId: 2,
brandName: "Ticca",
isGun: true
},
created: "2015-04-09T12:06:37",
lotn: "1111",
productId: 1
}
HTML
<select data-ng-model="products.brandBrandId"
data-ng-options="brand.brandName for brand in brandBrandId">
控制器
$scope.productService = productService;
$scope.products = productService.query();
console.log('$scope.products---->' + $scope.products.length)//Always 0!!!!
$scope.$watch('products.length', function (length) {
if (length) { // <= first time length is changed from undefined to 0
console.log('(watch) ' + $scope.products.length); // <= will log correct length aka 1
}
});
$scope.productService=productService;
$scope.products=productService.query();
console.log('$scope.products-->'+$scope.products.length)//始终为0!!!!
$scope.$watch('products.length',函数(length){
如果产品中p的(长度){/data ng options=“p.brandId.brandId为(p.brandId.brandName+”(“+p.brandId.brandId+”)”),则“
就是这样,谢谢!