samedi 21 février 2015

Angularjs with Typescript Error: [ng:areq] Argument 'IndexViewModel' is not a function, got undefined


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="http://ift.tt/17m7WTP"></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://ift.tt/1B1u6H6
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?





Aucun commentaire:

Enregistrer un commentaire