生产编译时出现未知的提供程序错误-带有Typescript的AngularJs

生产编译时出现带有Typescript错误的AngularJs

当尝试使用webpack进行生产编译时出现问题(可以使用velopment编译)。我遇到一个错误:“

  

[$ injector:unpr]:tProvider

这是我的代码:

App.ts:

import * as angular from "angular";
const app = angular.module("app",[require('angular-animate')]);

import { productsService } from "./services/productsService";
app.service("productsService",productsService);

import { dataService } from "./services/dataService";
app.service("dataService",["$rootscope",dataService]);

import { ProductsComponent } from "./components/ProductsComponent"; 
app.component("productscomponent",new ProductsComponent());enter code here

产品服务:

export class productsService {

   constructor() {}

   products():Array<IProduct> {
      const array:Array<IProduct> = [
        //...array of products
        ];

       return array;
    }
}

数据服务:

//imports...
export class dataService {
   static $inject = [
       '$rootscope'
   ];
   constructor($rootscope: ng.IrootscopeService) {
       /...
   }
   //methods in service...
   }

产品组件:

    //import
    export class ProductComponent implements ng.IComponentOptions {
    //variables...

    constructor() {
      this.controller = ProductsComponentController;
      this.controllerAs = "$ctrl";
      this.template = `
        //template...
      `;
    }
 }

ProductsComponentController:

//imports

export class ProductsComponentController implements ng.IComponentController {
   //variables...
   constructor($rootscope: ng.IrootscopeService,dataService:dataService,productsService:productsService) {
       //...
   }

   public $onInit ():void {
       //variables...
       //methods...
   }
}
xb588172 回答:生产编译时出现未知的提供程序错误-带有Typescript的AngularJs

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3159667.html

大家都在问