gpt4 book ai didi

angularjs - Angular.js flash 的模板内容

转载 作者:行者123 更新时间:2023-12-04 10:53:00 26 4
gpt4 key购买 nike

我有一个相当简单的页面,它调用 2 个静态 json 文件来填充它,如果我快速查看,我在 FF 和 chrome 中注意到的是我在运行时在页面中看到标签,然后它们一秒钟后更新(字面意思) 500 毫秒后)

这是一个简短的视频。

http://screencast.com/t/RZhEIxKj5

这是瀑布的样子

http://screencast.com/t/Be3JvLIYK00P

这是 Controller 的样子

function HotelsController($scope, $http) {
$http.get('data/hotels.json').then(function(res){
$scope.hotels = res.data;
});
}


function ConfirmationsController($scope, $http) {
$http.get('data/confirmations.json').then(function(res){
$scope.confirmations = res.data;
if ($scope.confirmations.length > 0) {
$scope.showConfirmations = "1";
}
else {
$scope.showConfirmations = "0";
}
});
}

这是我的 json 的样子
[
{
"nights": 2,
"hotel": "Hotel McCormick Place",
"confirmationNumber": "2345J453",
"checkIn": "18-Dec",
"checkOut": "20-Dec",
"roomType": "King, None-Smoking"
},
{
"nights": 1,
"hotel": "ABC Inn",
"confirmationNumber": "1234567",
"checkIn": "20-Dec",
"checkOut": "21-Dec",
"roomType": "Standard, None-Smoking"
}
]

[
{
"name": "Empire Hotels",
"img": "http://placehold.it/96x64",
"address": "123 Main Street, Texas"
},
{
"name": "Lemon Tree Hotel",
"img": "http://placehold.it/96x64",
"address": "123 Main Street, Texas"
},
{
"name": "Palm Fiber",
"img": "http://placehold.it/96x64",
"address": "123 Main Street, Texas"
}
]

最佳答案

使用 ng-cloak类来控制这个闪光灯。在 angular 的常见问题页面查看详细帮助 — http://docs.angularjs.org/api/ng.directive:ngCloak

在模板中:

<div ng-app class="ng-cloak">

</div>

在 CSS 中:
.ng-cloak {
opacity: 0;
}

关于angularjs - Angular.js flash 的模板内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17054640/

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