gpt4 book ai didi

javascript - 从 $http 执行 GET 调用后无法更新 $scope

转载 作者:行者123 更新时间:2023-11-30 15:58:31 25 4
gpt4 key购买 nike

我正在使用 visual studio 开发 Cordova-Hyrbrid 应用程序。对于选择控件,我使用名为 ionic-model-select ( http://inmagik.github.io/ionic-modal-select ) 的插件。

select 的值应该来自 webapi 调用。如果我调试,我可以看到 $scope.language 正在填充,但是,选择显示空白窗口。

我在调用后尝试了 $scope.$apply() 和 $scope.$digest(),但是它不起作用。知道为什么我没有在选择控件中获取值吗?

angularjs 代码:

        $http.get(sharedProperties.getURLOfLanguagesWebAPI()).then(function (data) {

allData = sharedProperties.convertXml2JSon(data.data);

for (var i = 0; i < allData.OVRLookupData.Languages.length; i++) {
$scope.languages.push({ "id": parseInt(allData.Languages[i].LanguageCode), "name": allData.Languages[i].Language });
}
$scope.$apply();
$scope.loadingLangues = false;

}, function (data) {
console.log(data);
});

HTML 是这样的:

            <div ng-show="!loadingLangues" ng-class="{'has-error':errLan}">
<label name="Language" class="item item-selectbox">
<span class="input-label" style="float:left">Select Language</span>
<button class="button button-dark button-outline icon-right ion-arrow-down-b"
modal-select ng-model="selectedValue"
options="languages"
on-select="languageChange(newValue)"
modal-title="Select Language">
{{ selectedValue.name || &apos;Select Language&apos;}}
<div class="option">{{option.name}}</div>
</button>
</label>
<label ng-if="errLan" class="item">
<span class="form-error item-text-wrap">Please select language.</span>
</label>
</div>

最佳答案

这是一个bug那是fixed yesterday .

由于 bower 包和 npm 包都没有更新,如果您想使用该功能,您需要从 GitHub 获取源代码。

关于javascript - 从 $http 执行 GET 调用后无法更新 $scope,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38125589/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com