gpt4 book ai didi

javascript - 设置 Angular JS 中包含的模板中的 $scope 变量的值

转载 作者:行者123 更新时间:2023-12-03 12:18:31 24 4
gpt4 key购买 nike

我有一个非常简单的设置,如下所示。我的问题是,我在 $http 的成功回调中设置的两个变量中,一个反射(reflect)在 UI 中,而另一个则没有。

正如您所看到的,我试图在 Controller 加载时显示进度,并在成功回调执行后隐藏它。但它不起作用,因为我在成功回调中设置的 false 似乎没有传播到 UI。

messages.html

<div>
<div ng-include="'partials/common/progress.tpl.html'"></div>
<div>{{message}}</div>

progress.tpl.html

<div ng-show="{{showProgress}}"  class="overlay" id="overlay"></div>

controller

app.controller('MessageController',['$scope','$http','ROOT_URL','$q',
function($scope,$http,ROOT_URL,$q) {
$scope.showSkipBtn = "false";
$scope.title = "Message of the Day";
$scope.showProgress = "true";
$http.get(ROOT_URL+'get_message_for_the_day').then(function(result){
$scope.message = result.data.message_of_the_day.replace(/\r?\n/g,'<br/>');
$scope.showProgress = "false";
console.log($scope.showProgress);
});
}])

最佳答案

在progress.tpl.html中删除showProgress周围的大括号

关于javascript - 设置 Angular JS 中包含的模板中的 $scope 变量的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24554866/

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