选择控制在ng-select之后丢失所有选项

时间:2015-01-27 12:17:53

标签: json angularjs drop-down-menu

我有一个像这样的选择框......

<select class="form-control m-b"
    ng-options="portfolios.id as portfolios.product_name for portfolios in portfolio"
    data-ng-model="portfolio" ng-change="getPriceAttributes()">
</select>

当用户从选择框中选择一个选项时,会调用函数getPriceAttributes() ...

(function() {

var app = angular.module('QuoteApp');

var quoteBuilderController = function($scope, $http) {

    $scope.formData = {};   

// this populates the select
    $http.get('scripts/json/sample-products.json')
        .then(function(res){
           $scope.portfolio = res.data.Connectivity;
        });

//this is called when a user selects an option from the select control
    $scope.getPriceAttributes = function() {
        $http.get('scripts/json/sample-product-attribute-response.json')
            .then(function(res){
                $scope.formFields = res.data;
            });
    };
};

app.controller('quoteBuilderController', ['$scope', '$http', quoteBuilderController]);

}());

当我加载页面时,选择框有一个来自json文件的选项列表。当我从选择框中选择一个选项时,会调用getPriceattributes(),但选择框中的选项会消失,留下一个空的选择控件。有谁知道为什么会发生这种情况?

谢谢

0 个答案:

没有答案