jQuery的metisMenu不工作里面NG-包括 [英] jquery metisMenu not working inside ng-include

查看:555
本文介绍了jQuery的metisMenu不工作里面NG-包括的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用的 NG-包括的呈现的模板。该模板需要的的jQuery插件metisMenu 的为下拉菜单。

I want to use ng-include to render the sidebar of the template. The template requires jQuery metisMenu plugin for dropdowns.

问题:仅插件的工作当我加载以下脚本部分模板'sidebar.html'里面:

Issue: Plugin only works when I load the following scripts inside the partial template 'sidebar.html':

<script src="//cdnjs.cloudflare.com/ajax/libs/metisMenu/1.1.0/metisMenu.js"></script>

<script>$(function() {
    $('#side-menu').metisMenu();
});</script>

失败当我尝试加载它们的里面的index.html

我要加载插件只有一次里面的 index.html的的,因为我可能需要在其他谐音为好。下面是这需要内部的谐音脚本加载工作模式的 Plunker 。请注意,从的 sidebar.html 的移动脚本的 index.html的的下拉菜单中停止工作。

I want to load the plugin only once inside index.html as I may require it in other partials as well. Here's a Plunker of the working model which requires script loading inside partials. Note that on moving scripts from sidebar.html to index.html the dropdown menu stops working.

任何帮助将是AP preciated。先谢谢了。

Any help would be appreciated. Thanks in advance.

推荐答案

我有同样的问题。你需要添加metisMenu();在你的主控制器:

I have the same problem. You need add metisMenu(); in your main controller:

app.controller('mainController', function($scope, Config) {
  $('#side-menu').metisMenu();
});

这篇关于jQuery的metisMenu不工作里面NG-包括的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆