从' Angular&#x27导入{angular}不在AngularJS中工作(1.5)
Angularjs -1.5 打字稿-1.8.10 webpack -1.15.0
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true
},
"exclude": [
"node_modules",
"typings",
"dist"
],
"compileOnSave": false,
"buildOnSave": false,
"atom": { "rewriteTsconfig": false }
}
我在./src/main/frontend/app/leftmenu/index.ts中遇到错误 时,找不到模块'angular'。
(1,21):错误ts2307:在我进行npm run build index.ts
import {angular} from 'angular';
import {MenuService} from './menuService';
import {LeftMenuController} from './leftmenu';
angular.module('tat')
.service('MenuService', MenuService)
.component('leftMenu',{
template : require('./leftmenu.html'),
controller : LeftMenuController,
controllerAs : 'lm'
});
请告诉我如何使我的索引可见角模块
。
AngularJS - 1.5
TypeScript - 1.8.10
WebPack - 1.15.0
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true
},
"exclude": [
"node_modules",
"typings",
"dist"
],
"compileOnSave": false,
"buildOnSave": false,
"atom": { "rewriteTsconfig": false }
}
I am getting ERROR in ./src/main/frontend/app/leftmenu/index.ts
(1,21): error TS2307: Cannot find module 'angular'. while i do a npm run build
index.ts
import {angular} from 'angular';
import {MenuService} from './menuService';
import {LeftMenuController} from './leftmenu';
angular.module('tat')
.service('MenuService', MenuService)
.component('leftMenu',{
template : require('./leftmenu.html'),
controller : LeftMenuController,
controllerAs : 'lm'
});
Please tell me how do I make the angular module visible to my index.ts
Note :: The angular module is present inside the node_modules.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将AngularJS作为默认模块导入。还建议将您的服务和组件作为角模块导出。这让您将所有内容作为ES6模块管理。
You should import AngularJS as a default module. Also suggest to export as default your services and components as angular modules. This let you manage all your stuff as ES6 modules.