【问题标题】:Module 'app' is not available! You either misspelled the module name or forgot to load it模块“应用程序”不可用!您要么拼错了模块名称,要么忘记加载它
【发布时间】:2018-01-18 09:04:41
【问题描述】:

我正在尝试使用带有 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>

【问题讨论】:

    标签: angularjs typescript


    【解决方案1】:

    添加 html 代码中的 angular.js 文件

    【讨论】:

      猜你喜欢
      • 2017-09-26
      • 2016-07-21
      • 2017-06-29
      • 1970-01-01
      • 1970-01-01
      • 2014-12-06
      • 1970-01-01
      • 2016-09-27
      • 1970-01-01
      相关资源
      最近更新 更多