1
我试图用JSPM 0.17.0
加载我的Angular 1.5.2
应用程序(用Typescript编写)。为什么我的Typescript导入只有在“console.log(myImport)”的情况下才有效?
这是我的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
,这不起作用↓
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)
?什么是我的导入语法损坏?
我想','angular.module后'分号( 'MyApp的',[ '主' ])'缺少 –
https://github.com/Microsoft/TypeScript /维基/ FAQ#为什么 - 是 - 进口感 - 省略的功能于我,EMIT –