加密冻结seconf后呼叫服务http

时间:2016-05-30 16:22:02

标签: javascript angularjs angularjs-ng-repeat loading

当我通过服务http获取数据时,我尝试进行加载,并且此数据进入范围变量并将数据显示为ng-repeat,如下所示:

<select class="" ng-model="selected_state" ng-change="getArrayCities(selected_state)" material-select watch>
                     <option value="" disabled selected>Choose a state</option>
                    <option ng-repeat="st in usa track by $index" value="{{st}}" >{{st.name}}</option>
</select>

<select class="" ng-model="selected_city" material-select watch ng-disabled="!selected_state">
                     <option value="" disabled selected>Choose a city</option>
                    <option ng-repeat="city in newArrayCities" >{{city.name}}</option>
</select>

控制器:

$scope.loaderRegister = false;
$scope.varloading = false;

    function getArrayCities(a){


                if(a != null){
                    $scope.loaderRegister = true;
                    $scope.varloading = true;

                    var state = JSON.parse(a);
                    ServiceCore.getCities(state.id)
                    .then(
                        function(r){
                            console.log("las ciudades Desde controller",r);
                            $scope.newArrayCities = r;
                            $scope.loaderRegister = false;
                            $scope.varloading = false;

                        },
                        function(e){
                            console.log(e);
                        }
                    );
                }else{

                }

                return true;
            }

问题是,我在调用de服务之前完成加载并完成重新启动数据我禁用加载,但加载冻结一秒钟(没有移动),然后消失。

我不知道为什么会发生这种情况,我认为等待重复完成,但我不知道..

任何帮助?

0 个答案:

没有答案