【问题标题】:rendering ng-bind with extra characters in the expression用表达式中的额外字符渲染 ng-bind
【发布时间】:2016-10-17 11:52:01
【问题描述】:

我使用ng-bind 来避免在呈现页面时看到我的{{variables}},它运行良好,除了当我添加() 的额外字符来包装它们看起来像的变量之一页面仍在渲染时为空()

<span ng-bind="(selected.id) + ' (' + (selected.serialnumber) + ') ' "></span>

任何建议的解决方案或解决方法?

【问题讨论】:

    标签: angularjs ng-bind-html ng-bind


    【解决方案1】:

    您可以使用ng-cloack

    ngCloak 指令用于阻止 Angular html 模板 浏览器在其原始(未编译)中短暂显示 加载应用程序时的表单。

    文档。 here

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Example - example-ng-cloak-production</title>
      
    
      <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
      
    
      
    </head>
    <body ng-app="">
      <u>with ng-cloak: (Expression hidden)</u>
     <div ng-cloak>{{ 'Hello world' }}</div>
     <div class="ng-cloak">{{ 'Hello world' }}</div>
      
     <u>without ng-cloak: (Expression visible first time)</u>
     <div>{{5+3+333+555}}</div>
     <div>{{ 'world' }}</div>
    </body>
    </html>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-06
      • 1970-01-01
      • 2015-02-11
      • 2015-08-31
      • 2023-03-18
      • 1970-01-01
      • 2018-02-18
      • 1970-01-01
      相关资源
      最近更新 更多