Javascript 捆绑打字稿中的执行顺序问题
Javascript execution order issue in bundled typescript
捆绑时生成的 javascript 的执行顺序有问题。
当我将它们捆绑在一起时出现此错误。
Uncaught Error: [$injector:nomod] Module 'app.demo' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
我相信我已经将范围缩小到 angular.module("app.demo").service()
在 angular.module("app.demo", [])
之前被调用 appbundle.js
.
我已经像这样设置了捆绑。在 visual studio 2013 年。
我的文件夹结构如下:
我把它像这样包含在我的 index.html 中。
<script src="App/appbundle.js"></script>
相关打字稿文件:
app.module.ts
module App {
"use strict";
// Create the module and define its dependencies.
angular.module("app", [
// Angular modules
"app.core",
"app.demo",
"app.services"
]);
}
demo.service.ts
module App.Services {
"use strict";
export interface IDemoService {
getData: () => Array<string>;
}
class demoService implements IDemoService {
static $inject: string[] = ["$http"];
constructor(private $http: ng.IHttpService) {
}
getData(): Array<string> {
return ["one", "two", "three"];
}
}
angular.module("app.services").service("demoService", demoService);
}
services.module.ts
module App.Services {
"use strict";
// Create the module and define its dependencies.
angular.module("app.services", []);
}
如前所述。我相信问题出在文件合并到 appbundle.js
.
中的顺序
所以我的问题是。 如何在保持捆绑功能的同时解决此问题?
我知道重命名文件会改变它们包含的顺序。但这不是我愿意做的事情:)
How do I fix this while keeping the bundling feature?
使用外部捆绑器,例如网页包。
更多:https://github.com/TypeStrong/atom-typescript/blob/master/docs/out.md
捆绑时生成的 javascript 的执行顺序有问题。 当我将它们捆绑在一起时出现此错误。
Uncaught Error: [$injector:nomod] Module 'app.demo' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
我相信我已经将范围缩小到 angular.module("app.demo").service()
在 angular.module("app.demo", [])
之前被调用 appbundle.js
.
我已经像这样设置了捆绑。在 visual studio 2013 年。
我的文件夹结构如下:
我把它像这样包含在我的 index.html 中。
<script src="App/appbundle.js"></script>
相关打字稿文件:
app.module.ts
module App {
"use strict";
// Create the module and define its dependencies.
angular.module("app", [
// Angular modules
"app.core",
"app.demo",
"app.services"
]);
}
demo.service.ts
module App.Services {
"use strict";
export interface IDemoService {
getData: () => Array<string>;
}
class demoService implements IDemoService {
static $inject: string[] = ["$http"];
constructor(private $http: ng.IHttpService) {
}
getData(): Array<string> {
return ["one", "two", "three"];
}
}
angular.module("app.services").service("demoService", demoService);
}
services.module.ts
module App.Services {
"use strict";
// Create the module and define its dependencies.
angular.module("app.services", []);
}
如前所述。我相信问题出在文件合并到 appbundle.js
.
所以我的问题是。 如何在保持捆绑功能的同时解决此问题?
我知道重命名文件会改变它们包含的顺序。但这不是我愿意做的事情:)
How do I fix this while keeping the bundling feature?
使用外部捆绑器,例如网页包。
更多:https://github.com/TypeStrong/atom-typescript/blob/master/docs/out.md