【发布时间】:2019-05-06 13:10:02
【问题描述】:
我设计了一个带有 javascript 的 htm 页面,一切运行良好, 但是当我试图将页面的一些 div 部分放在模板中时 angularjs应用程序所有需要javascript才能正确显示的元素都不起作用 正确或正确显示元素。 我后来发现 angular 有自己的 jquery 等。但问题是我正在使用一些 非定制元素和对代码进行更改可能会导致整个程序失败。
我该怎么做才能让所有部分正常工作?
这是角截面
var app = angular.module("app",[]);
app.controller("controls",["$scope", function($scope){
}]);
app.directive("myTemplate", function(){
return{
templateUrl: "template_file_with_div_section.htm"
};
});
HTM 部分
<div ng-controller="controls">
<div my-template></div>
</div>
有些部分正在使用数据表等
some the scripts i am using are
<script src="angular/angular.js"></script>
1. jquery.min.js
2. tables/jquery-datatable.js
3. jquery-datatable/jquery.dataTables.js
4. jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js
5. jquery-datatable/extensions/export/dataTables.buttons.min.js
有超过 50 种不同的 jquery 脚本
更新
当我通过http://url/#template_name 输入模板的网址时 该模板显示在网页中,因此它显示它工作正常,但模板中的某些部分将执行一些操作(例如排序等),这些部分依赖于主页中的 javascript。
这些部分根本不起作用。
当我将角度脚本放在表格脚本之后。模板没有出现, 但是当我将 angular 脚本放在如上所示的表格脚本之后时,模板出现了,但脚本根本不起作用
【问题讨论】:
-
有什么问题?
-
你在 html 中定义了 ng-app 吗?
-
是的,我已经定义了 ng-app
标签: javascript jquery angularjs