Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 如何使用ng选项创建下拉列表_Angularjs_Ng Options - Fatal编程技术网

Angularjs 如何使用ng选项创建下拉列表

Angularjs 如何使用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

来自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.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+”)”),则“
就是这样,谢谢!