【发布时间】:2014-05-30 14:43:23
【问题描述】:
我想用另一个文件的内容填充 anglarjs 函数的内容。可以是js文件,json,txt,我不介意。
test.js
$scope.startTest = function () {
/**
* insert content of details-1.js
*/
}
detials-1.js
var fac = 3;
return fac;
这样最终的函数看起来像
$scope.stratTest = function() {
var fac = 3;
return fac;
}
我的目标是根据您选择的测试制定不同的测试程序,并从 startTest 函数启动特定的测试程序。
【问题讨论】:
-
您为什么要这样做?您尝试解决的问题可能有更好的解决方案。
-
除了@JonKoops 评论 - meta.stackexchange.com/questions/66377/what-is-the-xy-problem
-
我的目标是根据您选择的测试有不同的测试程序,并从 startTest 函数开始一个特定的程序。
-
编写函数来做所有你想做的事情,并让你的输入文件只包含一个数字,表明你想运行哪个测试。
-
通常 javascript 使用 AMD 或 CommonJS 模块将文件分开。您通常导入整个函数,而不是函数的内容。
标签: javascript angularjs file