我有一个相当简单的页面,它调用2个静态json文件来填充它以及我在FF和chrome中注意到的内容如果我看起来很快就是我在页面中看到运行时的标签然后它们会更新一秒钟之后(字面意思是500毫秒后)
这是一段简短的视频。
http://screencast.com/t/RZhEIxKj5
这是瀑布的样子
http://screencast.com/t/Be3JvLIYK00P
这是控制器的样子
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"
}
]
答案 0 :(得分:11)
使用ng-cloak
类来控制此闪光灯。查看详细信息帮助查看角度常见问题解答页面 - http://docs.angularjs.org/api/ng.directive:ngCloak
在模板中:
<div ng-app class="ng-cloak">
…
</div>
在CSS中:
.ng-cloak {
opacity: 0;
}