我是$injecting loginService
方法的loginController
,但它一直在抛出
[ng:areq] 参数'fn'我们不是函数错误。
我正在使用angularjs与打字稿 这是我正在做的代码演示 LoginController.ts - >
import { Login, LoginModel } from './login.model';
import { LoginService } from './login.service';
import { IScope } from 'angular';
export class LoginController {
public static $inject : Array<string> = ['$scope','LoginService'];
user = new LoginModel();
constructor($scope : IScope ,private loginService : LoginService){
this.loginService = loginService;
}
}
Login.ts - &gt;
import * as angular from "angular";
import { LoginController } from "./login.controller";
import * as ui from "@uirouter/angularjs";
const loginTemplate : any = require('./login.html');
import { LoginService } from './login.service';
import { BaseapiService } from "../services/baseapi.service.";
export const loginModule = angular.module('loginModule',[])
.config(["$stateProvider",($stateProvider:ui.StateProvider)=>{
$stateProvider
.state('login',{
url :'/login',
template : loginTemplate ,
controller : LoginController,
controllerAs : 'vm'
})
}])
.service('LoginService',[LoginService.id])
// .service('baseapiService',[BaseapiService.id])
.run(['$log',($log:ng.ILogService,)=>{
$log.log('Navbar module loaded.')
}])
和LoginService.ts - &gt;
import { BaseapiService } from '../services/baseapi.service.';
export class LoginService{
public static $inject :Array<string> = ['$http','$q','$mdToast','baseapiService']
static id = 'LoginService';
http : ng.IHttpService;
q : ng.IQService;
mdToast : ng.material.IDialogService;
constructor(
private $http : ng.IHttpService,
private $q : ng.IQService,
private $mdToast : ng.material.IDialogService,
private baseapiService : BaseapiService
){
this.http = $http;
this.q = $q;
this.mdToast = $mdToast;
this.baseapiService = baseapiService;
}
}
我登录.ts是我创建登录模块的主文件,并将此模块注入main.ts文件。 提前谢谢你