【问题标题】:Angular ui bootstrap popover with template带有模板的 Angular ui 引导弹出窗口
【发布时间】:2016-01-16 23:10:19
【问题描述】:
<a data-ng-href="" uib-popover-template="'profile.html'" popover-placement="bottom"></a>

<script type="text/ng-template" id="profile.html">
    <div class="media">
        <div class="media-left">
            <a data-ng-href="">
                <img class="media-object" data-ng-src="" alt="">
            </a>
        </div>
        <div class="media-body">
            <h4 class="media-heading" data-ng-bind="mainCtrl.Authentication.getUser().fullName">Unknown User</h4>
        </div>
    </div>
</script>

错误

Error: Syntax error, unrecognized expression: <div class="media">
        <div class="media-left">
            <a data-ng-href="">
                <img class="media-object" data-ng-src="" alt="">
            </a>
        </div>
        <div class="media-body">
            <h4 class="media-heading" data-ng-bind="mainCtrl.Authentication.getUser().fullName">Unknown User</h4>
        </div>
    </div>
    at Function.Sizzle.error (jquery.js:4421)
    at tokenize (jquery.js:5076)
    at select (jquery.js:5460)
    at Function.Sizzle [as find] (jquery.js:3998)
    at jQuery.fn.extend.find (jquery.js:5576)
    at jQuery.fn.jQuery.init (jquery.js:196)
    at jQuery (jquery.js:62)
    at compile (angular.js:7543)
    at ui-bootstrap-tpls.js:4688
    at processQueue (angular.js:14792)

我创建了一个带有引导组件的模板,我正在使用这个模板来创建引导弹出窗口。谁能纠正我的错误

【问题讨论】:

    标签: javascript jquery angularjs twitter-bootstrap angular-ui-bootstrap


    【解决方案1】:

    我今天遇到了这个问题,当我准备发布同样的问题时,当我输入我的帖子标题时,我遇到了this post。这反过来又把我带到了jquery documentation

    基本上我所做的是去除模板中的空格,它工作正常。即:

    之前:

    <script type="text/ng-template" id="deletePopover.html">
        <div>Sample template.</div>
    </script>
    

    之后:

    <script type="text/ng-template" id="deletePopover.html"><div>Sample template.</div>
    </script>
    

    由于 Angular UI Bootstrap 不依赖于 jQuery,我不知道为什么这是一个问题,而且我还没有真正研究过为什么会这样,我想我会在此期间发布它。

    【讨论】:

      【解决方案2】:

      遇到了同样的问题。解决了更改加载 jquery 和引导程序的顺序。现在我加载引导程序,然后加载 jquery,它似乎解决了它。但还是很奇怪。

      【讨论】:

        【解决方案3】:

        只想指出,要求的根源似乎是字符串必须以&lt; 字符开头。所以你实际上不需要把整个东西放在一行上(这对于更复杂的模板来说不是很好)。以下对我有用:

        <script type="text/ng-template" id="template.html"><span></span>
            <div>
                Hello there
            </div>
        </script>
        

        在打开 &lt;script&gt; 之后立即使用 &lt;span&gt;&lt;/span&gt; 可以将模板的其余部分呈现为 HTML。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多