jquery - 如何在 Angular Controller 中使用 Typeahead JS 定位 Bootstrap 模式

标签 jquery html angularjs twitter-bootstrap typeahead.js

我使用的是 Bootstrap、typeahead JS 和 angular。我无法从 Angular Controller 中的 typeahead 模板中定位 Bootstrap 模式。它无法识别必须以 HTML 中的模态为目标的页脚中的 Angular 表达式。这可能与不识别 Angular 表达式的模板有关。

所以,我想从模板的页脚定位 BS 模态。是否有适当的解决方案来完成这项工作?

查看我的代码:

    <div id="something{{some.id}}" class="modal fade bs-example-modal-sm"    tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel"
         aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                   header here...
                </div>
                <div class="modal-body">
                    content here...
                </div>
                <div class="modal-footer">
                   footer here...
                </div>
            </div>
         </div>
    </div>    



// code in angular controller:

    events.initialize();
    $scope.eventsDataset = {
        name: 'events',
        displayKey: 'title',
        source: events.ttAdapter(),
        templates: {
            empty: 'this is empty',
            suggestion: Handlebars.compile ('<p>{{title}}</p>'),
            footer: '<p class="footer" data-toggle="modal" data-target= "#something{{some.id}}">you can click here..</p>'
        }
    };
    $scope.exampleOptions = {
        highlight: true
    };`enter code here`

最佳答案

Remove the # in the id attribute for your modal window div.

作为侧节点,为页脚提供如下所示的结构而不是字符串。在我看来,它将更具可读性和可维护性。

footer: function() {
  return $('<p></p>')
    .addClass('footer')
    .attr('data-toggle', 'modal')
    .attr('data-target', '#something1')
    .html('click me');
}

这是一个 demo 显示相同

希望这对您有所帮助。

关于jquery - 如何在 Angular Controller 中使用 Typeahead JS 定位 Bootstrap 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29818762/

相关文章:

javascript - IE 中 JavaScript 函数的故障排除

jquery - 错误 :$ ("#menu ul.menu"). lavalamp 不是函数

javascript - 使用javascript专注于文本框

angularjs - 使用 Protractor 的 switchTo 定位非 Angular iframe 的元素

jquery - 隐藏类的所有实例(单击的实例除外)

html - CSS中的边框框和内容框有什么区别?

html - 在 Angular 为 2 的条件上添加属性

javascript - AngularJS ng-Cloak 不起作用

javascript - 在加载时绑定(bind) ng-model 中的 ng-options(类似于双向绑定(bind))

javascript - 如何正确地从我的 Controller 返回注释并在 .done() AJAX 函数中使用它?