以打字稿错误Angularjs:[NG:AREQ]参数'IndexViewModel“不是一个函数,得到了不确定 [英] Angularjs with Typescript Error: [ng:areq] Argument 'IndexViewModel' is not a function, got undefined

查看:177
本文介绍了以打字稿错误Angularjs:[NG:AREQ]参数'IndexViewModel“不是一个函数,得到了不确定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试一个简单的HTML打字稿应用程序,并不能让过去试图Angularjs集成到解决方案时在主题指出这个错误。基本上,我有一个简单的index.html页面如下:

 <!DOCTYPE HTML>< HTML LANG =ENNG-应用>
< HEAD>
    <间的charset =UTF-8/>
    <标题>打字稿HTML应用与LT; /标题>
    <链接rel =stylesheet属性HREF =app.css类型=文/ CSS/>
    &所述;脚本数据需要=angular.js@*数据semver =1.3.13SRC =的https://$c$c.angularjs.org/1.3.13/angular.js>&下; / SCRIPT>
    &所述; SCRIPT SRC =app.js>&下; /脚本>
< /头>
<机身NG控制器=Infrastructure.IndexViewModel>
    < H1>打字稿HTML应用与LT; / H1>    < D​​IV ID =内容>< / DIV>
< /身体GT;
< / HTML>

我创建了一个名为IndexViewModel简单的类如下:

模块LogsModule {
    出口类LogsViewModel {
        构造函数($范围:ng.IScope,$ HTTP:ng.IHttpService){
            console.info(日志查看模型构建。);
        }
    }
}

我还设置在Visual Studio设置,以确保所有的打字原稿的文件被组合成一个单一的JavaScript文件。

当我运行应用程序,我得到的错误:

 错误:[NG:AREQ]参数'Infrastructure.IndexViewModel不是一个函数,得到了不确定
http://errors.angularjs.org/1.3.13/ng/areq?p0=Infrastructure.IndexViewModel&p1=not%20a%20function%2C%20got%20undefined
    在angular.js:63
    在assertArg(angular.js:1580)
    在assertArgFn(angular.js:1590)
    在angular.js:8431
    在angular.js:7599
    在的forEach(angular.js:331)
    在nodeLinkFn(angular.js:7586)
    在compositeLinkFn(angular.js:7078)
    在compositeLinkFn(angular.js:7081)
    在publicLinkFn(angular.js:6957)

我有参考并的这个等等,但仍然感到困惑。我错过了什么?


解决方案

  

我创建了一个名为IndexViewModel简单的类,如下所示:
  模块LogsModule {出口类LogsViewModel {构造函数($范围:ng.IScope,$ HTTP:ng.IHttpService){console.info(日志查看模型构建。); }}}


类叫做 LogsViewModel 及其 LogsModule 。因此, NG-控制器=Infrastructure.IndexViewModel> NG-控制器=LogsModule.LogsViewModel>

Attempting a simple HTML TypeScript application and cannot get past this error noted in the subject when attempting to integrate Angularjs into the solution. Basically, I have a simple index.html page as follows:

<!DOCTYPE html>

<html lang="en" ng-app>
<head>
    <meta charset="utf-8" />
    <title>TypeScript HTML App</title>
    <link rel="stylesheet" href="app.css" type="text/css" />
    <script data-require="angular.js@*" data-semver="1.3.13" src="https://code.angularjs.org/1.3.13/angular.js"></script>
    <script src="app.js"></script>
</head>
<body ng-controller="Infrastructure.IndexViewModel">
    <h1>TypeScript HTML App</h1>

    <div id="content"></div>


</body>
</html>

I have created a simple class called IndexViewModel as follows:

module LogsModule { export class LogsViewModel { constructor($scope: ng.IScope, $http: ng.IHttpService) { console.info("logs view model constructed."); } } }

I have also set the Visual Studio setting to ensure that all TypeScript files are combined into a single JavaScript file.

When I run the application, I get the error:

Error: [ng:areq] Argument 'Infrastructure.IndexViewModel' is not a function, got undefined
http://errors.angularjs.org/1.3.13/ng/areq?p0=Infrastructure.IndexViewModel&p1=not%20a%20function%2C%20got%20undefined
    at angular.js:63
    at assertArg (angular.js:1580)
    at assertArgFn (angular.js:1590)
    at angular.js:8431
    at angular.js:7599
    at forEach (angular.js:331)
    at nodeLinkFn (angular.js:7586)
    at compositeLinkFn (angular.js:7078)
    at compositeLinkFn (angular.js:7081)
    at publicLinkFn (angular.js:6957)

I have referenced this and this among others but still confused. What did I miss?

解决方案

I have created a simple class called IndexViewModel as follows: module LogsModule { export class LogsViewModel { constructor($scope: ng.IScope, $http: ng.IHttpService) { console.info("logs view model constructed."); } } }

The class is called LogsViewModel and its in LogsModule. So ng-controller="Infrastructure.IndexViewModel"> should be ng-controller="LogsModule.LogsViewModel">

这篇关于以打字稿错误Angularjs:[NG:AREQ]参数'IndexViewModel“不是一个函数,得到了不确定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆