简体   繁体   English

Angular 1打字稿项目中的依赖注入

[英]Dependency injection in angular 1 typescript project

I am trying to use angular-jwt with typescript in my angular1 project. 我正在我的angular1项目中尝试将angular-jwt与typescript一起使用。 I installed angular-jwt by using 我通过使用安装了angular-jwt

typings install dt~angular-jwt --global

I have it in the typings>globals>angular-jwt but there is no angular-jwt in the typings.json file. 我在Typeings> globals> angular-jwt中有它,但是在typings.json文件中没有angular-jwt。 Is this a problem? 这有问题吗?

Also I get and error: Module ngJwtAuth is not available! 我也得到和错误:模块ngJwtAuth不可用! while i try to use it a dependency. 而我尝试使用它的依赖项。

import * as angular from 'angular';
import 'angular-jwt';

angular.module('app', ['ngJwtAuth']);

Any idea how to fix this? 任何想法如何解决这个问题?

This happens because ngJwtAuth module wasn't defined. 发生这种情况是因为ngJwtAuth模块。

Module's name is angular-jwt , not ngJwtAuth . 模块的名称是angular-jwt ,而不是ngJwtAuth

The absence of a package in typings.json is a problem because it won't be installed for cloned repo. typings.json缺少软件包是一个问题,因为它将不会为克隆的回购安装。 To save the package in typings.json it should be 要将包保存在typings.json 它应该是

typings install dt~angular-jwt --global --save

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM