【发布时间】:2015-03-31 17:52:37
【问题描述】:
考虑以下
<html ng-app="crudModule">
@{
ViewBag.Title = "Index";
}
<body ng-controller="crudController">
<table id="tblContainer" border="1">
<thead>
<tr>
<th>EmpName</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="emp in Employees" my-employee="emp"></tr>
</tbody>
</table>
<script type="text/ng-template" id="Employee.html">
<tr>
<td> <span>{{_employee.EmployeeId}}</span></td>
</tr>
</script>
</body>
</html>
<script src="~/Scripts/angular.js"></script>
<script src="~/Scripts/angular-route.js"></script>
<script src="~/Scripts/MyScripts/Module.js"></script>
<script src="~/Scripts/MyScripts/Service.js"></script>
<script src="~/Scripts/MyScripts/Controller.js"></script>
<script src="~/Scripts/MyScripts/Builder.js"></script>
<script src="~/Scripts/MyScripts/Utility.js"></script>
同一页面中有很多外部 javascript 文件。
有没有什么好的方法可以让页面只有一个 JS 文件,而其他的都在那个里面或任何其他方式?
【问题讨论】:
-
您可以使用grunt-contrib-concat 之类的服务。首先你需要安装
node,然后是grunt,但是这样做的好处是巨大的。 -
查看 requirejs @ requirejs.org - 我从未使用过它,但它听起来像你要找的东西
标签: javascript