避免angular出现{{}}
在angular中运用{{}}刷新时有时会出现“{{}}”,严重影响用户体验。
解决办法是在{{}}包裹的html标签中添加ng-cloak,即可解决
1 <!doctype html> 2 <html ng-app="myApp"> 3 <head> 4 <script src="//cdn.bootcss.com/angular.js/1.2.0rc3/angular.js"></script> 5 </head> 6 <body ng-controller="myControl"> 8 <p ng-cloak >{{ greeting}}</p> 9 10 <script> 11 angular.module('myApp'[]) 12 .controller('myControl',function($scope, $timeout) { 13 $timeout( function (){ updateVal() }, 1000); 14 var updateVal = function() { 15 $scope.greeting = 1; 16 }; 17 }); 18 </script> 19 </body> 20 </html>