jQuery脚本不在ng-include文件中工作

时间:2015-03-05 07:19:10

标签: javascript jquery angularjs angularjs-ng-include

我在template.js文件中有一些逻辑用于整个应用程序。 如果我按部分开始'切割'应用程序并包括使用ng-include, jQuery'逻辑'(来自template.js)不适用于包含文件,但如果我将其粘贴到包含的文件中,则可以正常工作,但是这样我在DOM中有重复的template.js。

示例:

index.html 
<html>
    <head>
        <...jQuery, angularJs, etc...>
        <script scr="template.js">
    </head>
    <body>
        <div>Example dropdown</div>
        <div ng-include="file1.html"></div>
    </body>
</html>

file1.html
<div>Example dropdown</div>
index.html中的

'示例下拉列表'有效但file1.html中的“示例下拉列表”不起作用。 它以这种方式工作:

index.html
<html>
    <head>
        <...jQuery, angularJs, etc...>
        <script scr="template.js">
    </head>
    <body>
        <div>Example dropdown</div>
        <div ng-include="file1.html"></div>
    </body>
</html>

file1.html
<script scr="template.js">
<div>Example dropdown</div>

但正如我们可以看到的那样,当所有内容都被加载时,我们会在DOM中收到重复的template.js。

如何使用.js文件和上面的示例来避免重复?

同样的问题:jquery metisMenu not working inside ng-include

0 个答案:

没有答案
相关问题