Angularjs $scope.$digest()不';t填充select2下拉列表

Angularjs $scope.$digest()不';t填充select2下拉列表,angularjs,ui-select2,angularjs-digest,Angularjs,Ui Select2,Angularjs Digest,我有两个使用ui-select2的下拉列表 <label class="control-label" for="MakeSelect">Make </label> <select class="form-control col-md-2" id="MakeSelect" name="make" ui-select2 ng-m

我有两个使用ui-select2的下拉列表

                        <label class="control-label" for="MakeSelect">Make </label>
                    <select class="form-control col-md-2" id="MakeSelect" name="make" ui-select2
                            ng-model="carDetails.make">
                        <option ng-if="!carDetails.make" value="">[SELECT]</option>
                        <option ng-repeat="make in makes" value="{{ make }}">{{ make}}</option>
                    </select>
                </div>
                <div class="col-md-5">
                <label class="control-label" for="ModelSelect">Model </label>
                <select class="form-control col-md-2" id="ModelSelect" name="make" ui-select2
                        ng-model="carDetails.model">
                    <option ng-repeat="model in models" value="{{ model }}">{{ make}}</option>
                </select>
问题是使用$digest时,第一个下拉列表的选定值将变为null,而不使用时,它不会刷新视图


有什么建议吗?

它们都指向同一个作用域模型cardetals.make。当然,第一个将变为null,因为第二个下拉列表将carDetails.make设置为null。另外,我认为您不需要使用摘要,尽管您应该使用$scope.$apply。但是,angularjs无论如何都应该运行摘要。

我上传了一个旧版本,但即使在我修复了它之后,它也不会填充它。我编辑了我的问题,谢谢。嗯,我唯一能看到的是,为了让ng模型在select上工作,必须有一个值为“”的选项。我认为您的模型下拉列表中没有“”的值。哦,两个选择都有相同的名称=“make”一个应该是make,另一个是model我不理解您的第一条评论,您能解释更多吗?很抱歉,AngularJs不会绑定到select html元素,除非它有一个值为“”的选项。所以只需将其添加到模型下拉列表中。[选择]
$scope.$watch('carDetails.make', function (make) {
    console.log('selected make is: ' + make);
    if (make == "") {
        return;
    }

    Parse.Cloud.run('getCarModels', {'Make': make}, {
        success: function (results) {
            $scope.parseModels = results.resultSet;
            $scope.models = results.distinctModels;
            $scope.$digest();
        },
        error: function () {
            console.log("Error: Failed to load models");
            console.log(Parse.Error);
        }
    });