我尝试使用JSPM 1.5.2
加载我的Angular 0.17.0
应用(使用Typescript编写)。
这是我的HTML:
<!DOCTYPE html>
<html ng-app="MyApp">
<head>
<meta charset="utf-8">
<title>My App</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="index.css">
<script src="jspm_packages/system.js"></script>
<script src="jspm.browser.js"></script>
<script src="jspm.config.js"></script>
</head>
<body>
<main first-name="huh" last-name="what"></main>
<script>
SystemJS.import('app.ts');
</script>
</body>
</html>
对于我的./app.ts
,此操作&#39; T工作↓
import $ from 'jquery'
import angular from 'angular'
import main from './components/main/main.ts';
module app {
angular.module('MyApp', [
'main'
])
}
// which gives me "[$injector:nomod] Module 'main' is not available!"
这项工作↓
import $ from 'jquery'
import angular from 'angular'
import main from './components/main/main.ts';
module app {
angular.module('MyApp', [
'main'
])
console.log(main);
}
// Now it works fine, no error.
那么为什么这会失败,除非我在模块声明中用console.log(main)
显式引用我的导入模块?我的导入语法有什么问题?