html在ng-if评估angularjs中的正则表达式之前显示结果

时间:2015-08-18 12:59:05

标签: javascript angularjs



<div class="alert alert-danger hidden-xs" role="alert" ng-if="OrderDetails.length == 0" style="font-size: large; font-stretch: expanded;
    font-weight: bold;">
  
  
<p>We're sorry,you currently have no last Order details, but items you've thought will be added automatically when you place an order.</p>
  
  
    </div>
&#13;
&#13;
&#13;

嗨,正如您从上面看到的,我的结果从控制器加载上面的html加载到我的浏览器上,有没有什么办法可以防止在我的结果加载之前加载这个div并可以在我的网页上显示?< / p>

2 个答案:

答案 0 :(得分:1)

查看 ng-cloak

的文档

来自文档:

  

ngCloak指令用于防止浏览器在加载应用程序时以原始(未编译)形式短暂显示Angular html模板。使用此指令可避免由html模板显示引起的不良闪烁效应。

<input id = "search"  ng-if="someCondition" ng-cloak> 

答案 1 :(得分:0)

您可以使用ng-bind read more

<p ng-bind="contentToShow"></p>

并在您的控制器中

$scope.contentToShow = "We're sorry,you currently have no last Order details, but items you've thought will be added automatically when you place an order.";