我正在尝试使用带有angularjs的打字稿来制作应用程序。但是我收到了这个错误
错误:[$ injector:nomod]模块' app'不可用!您要么错误拼写了模块名称,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。
app.ts是
import * as angular from 'angular';
import IModule = ng.IModule;
export class App{
public static bootstrap():void{
const app : IModule = angular.module('app',).component('sachin',{
template:'<div>sdafdsfa</div>',
controller:[function(){
}],
controllerAs:'vm'
})
angular.bootstrap(document, ["app"], {
"strictDi": true,
});
}
}
index.html
<!DOCTYPE html>
<html lang="en" ng-app="app" >
<head>
<title>My AngularJS App with ts</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<sachin></sachin>
<script src="vendors.js"></script>
<script src="bundle.js"></script>
</body>
</html>
答案 0 :(得分:0)
添加 你的html代码中的angular.js文件