AngularJS ng-view没有加载js

时间:2022-06-12 13:02:12

I have a problem with my AngularJS app. I'm trying to use a JavaScript of a bootstrap template inside of a ng-view, but is not working. When I use this JavaScript in my index works great, but not inside of any view.

我的AngularJS应用程序有问题。我正在尝试在ng-view中使用引导程序模板的JavaScript,但是不起作用。当我在我的索引中使用这个JavaScript时效果很好,但不在任何视图中。

This is a part of my index.html:

这是我的index.html的一部分:

    <!-- Breadcrumb -->

    <ng-view>
    </ng-view>
    <!-- Javascript Libraries -->
    <!-- jQuery -->
    <script src="js/jquery.min.js"></script> <!-- jQuery Library -->
    <script src="js/jquery-ui.min.js"></script> <!-- jQuery UI -->
    <script src="js/jquery.easing.1.3.js"></script> <!-- jQuery Easing - Requirred for Lightbox + Pie Charts-->

    <!-- Bootstrap -->
    <script src="js/bootstrap.min.js"></script>

    <!--  Form Related -->
    <script src="js/select.min.js"></script> <!-- Custom Select -->
    <script src="js/chosen.min.js"></script> <!-- Custom Multi Select -->
    <script src="js/datetimepicker.min.js"></script> <!-- Date & Time Picker -->
    <script src="js/colorpicker.min.js"></script> <!-- Color Picker -->
    <script src="js/icheck.js"></script> <!-- Custom Checkbox + Radio -->

When I use some of the features of any of the form related scripts inside of a ng-view don't work.

当我使用ng-view中任何与表单相关的脚本的某些功能时,这些功能都不起作用。

How can I use this scripts inside my ng-views?? I've tried to load the scripts inside the ng-views but still doesn't work.

如何在ng-views中使用这个脚本?我试图在ng-views中加载脚本但仍然无效。

1 个解决方案

#1


5  

It's hard to see from your code snippet, but have you tried loading jquery before angularjs file ? Angular works with jqLite and if your not loaded jQuery before angularjs file angular tries to load it with jqLite.

从你的代码片段中很难看到,但你是否尝试过在angularjs文件之前加载jquery? Angular与jqLit​​e一起使用,如果你在angularjs文件angular之前没有加载jQuery试图用jqLit​​e加载它。

But, it is preffered to convert your jquery plugins to a directive in order for them work properly in your angular project.

但是,优先将jquery插件转换为指令,以便它们在角度项目中正常工作。

#1


5  

It's hard to see from your code snippet, but have you tried loading jquery before angularjs file ? Angular works with jqLite and if your not loaded jQuery before angularjs file angular tries to load it with jqLite.

从你的代码片段中很难看到,但你是否尝试过在angularjs文件之前加载jquery? Angular与jqLit​​e一起使用,如果你在angularjs文件angular之前没有加载jQuery试图用jqLit​​e加载它。

But, it is preffered to convert your jquery plugins to a directive in order for them work properly in your angular project.

但是,优先将jquery插件转换为指令,以便它们在角度项目中正常工作。