找不到命名空间
Cannot find namespaces
我在我的 Angular 2 应用程序中使用 ADAL 进行身份验证
编译时出现以下错误。
ERROR in C:/abc/src/app/services/adal.service.ts (5,26): Cannot find namespace 'adal'.
ERROR in C:/abc/src/app/services/adal.service.ts (5,61): Cannot find name 'AuthenticationContext'.
ERROR in C:/abc/src/app/services/adal.service.ts (10,22): Cannot find namespace 'adal'.
webpack: Failed to compile.
adal.service.ts
----------------------------
import {ConfigService} from './config.service';
import {Injectable} from '@angular/core';
import 'expose-loader?AuthenticationContext!../../../node_modules/adal-angular/lib/adal.js';
let createAuthContextFn: adal.AuthenticationContextStatic = AuthenticationContext;
@Injectable()
export class AdalService {
private context: adal.AuthenticationContext;
我是否缺少任何进口商品?
也许您需要 TypeScript 定义。尝试在项目的根目录中使用 npm install --save-dev @types/adal
安装。
另一种可能的解决方案:
import * as adal from 'expose-loader?AuthenticationContext!../../../node_modules/adal-angular/lib/adal.js'
或
import {ConfigService} from './config.service';
import {Injectable} from '@angular/core';
import { adal, AuthenticationContext, AuthenticationContextStatic } from 'expose-loader?AuthenticationContext!../../../node_modules/adal-angular/lib/adal.js';
let createAuthContextFn: AuthenticationContextStatic = AuthenticationContext;
@Injectable()
export class AdalService {
private context: AuthenticationContext;
}
通过在 .angular-cli.json
中添加以下代码解决了这个问题
"scripts": [
"../node_modules/adal-angular/lib/adal.js"
]
我在我的 Angular 2 应用程序中使用 ADAL 进行身份验证
编译时出现以下错误。
ERROR in C:/abc/src/app/services/adal.service.ts (5,26): Cannot find namespace 'adal'.
ERROR in C:/abc/src/app/services/adal.service.ts (5,61): Cannot find name 'AuthenticationContext'.
ERROR in C:/abc/src/app/services/adal.service.ts (10,22): Cannot find namespace 'adal'.
webpack: Failed to compile.
adal.service.ts
----------------------------
import {ConfigService} from './config.service';
import {Injectable} from '@angular/core';
import 'expose-loader?AuthenticationContext!../../../node_modules/adal-angular/lib/adal.js';
let createAuthContextFn: adal.AuthenticationContextStatic = AuthenticationContext;
@Injectable()
export class AdalService {
private context: adal.AuthenticationContext;
我是否缺少任何进口商品?
也许您需要 TypeScript 定义。尝试在项目的根目录中使用 npm install --save-dev @types/adal
安装。
另一种可能的解决方案:
import * as adal from 'expose-loader?AuthenticationContext!../../../node_modules/adal-angular/lib/adal.js'
或
import {ConfigService} from './config.service';
import {Injectable} from '@angular/core';
import { adal, AuthenticationContext, AuthenticationContextStatic } from 'expose-loader?AuthenticationContext!../../../node_modules/adal-angular/lib/adal.js';
let createAuthContextFn: AuthenticationContextStatic = AuthenticationContext;
@Injectable()
export class AdalService {
private context: AuthenticationContext;
}
通过在 .angular-cli.json
中添加以下代码解决了这个问题"scripts": [
"../node_modules/adal-angular/lib/adal.js"
]