각도 및 TypeScript를 사용하여 새 MVC 5 프로젝트를 설정하고 있습니다. 컨트롤러와 서비스를 인스턴스화하는 데 문제가 있습니다.각도 "angular.js : 14110 오류 : [ng : areq] 인수 'fn'이 함수가 아닙니다. 정의되지 않았습니다."컨트롤러 인스턴스화시 예외입니다.
app.ts :
module mqApp {
'use strict';
if (typeof (angular) != "undefined") {
var modules;
modules = [];
angular.module("mqApp", modules)
.controller("MasterController", MasterController)
.service("UserService", UserService);
}
}
userService.ts :
module mqApp {
'use strict';
export class UserService {
public static $inject = [
'$scope',
'$http',
'$window'
];
private scope: angular.IScope;
private httpSvc: angular.IHttpService;
private window: angular.IWindowService;
constructor($scope: angular.IScope, $http: angular.IHttpService, $window) {
this.scope = $scope;
this.httpSvc = $http;
this.window = $window;
alert(2);
}
logOff() {
this.httpSvc.get('/Account/LogOff');
this.window.location.href = '/';
}
}
}
다음
angular.js:14110 Error: [ng:areq] Argument 'fn' is not a function, got undefined
내 설정이다 : 내 HTML에서 NG 컨트롤러를 포함 할 때 다음과 같은 오류가
masterController.ts :
module mqApp {
'use strict';
export class MasterController {
public static $inject = [
'$scope',
'UserService'
];
private userService: UserService;
private scope: angular.IScope;
contructor($scope: angular.IScope, userService: UserService) {
alert(1);
this.userService = userService;
this.scope = $scope;
}
}
}