Angularjs,组件单元测试由于未知的提供程序错误而失败

时间:2016-09-27 07:19:32

标签: angularjs unit-testing typescript

我在angularjs单元测试中得到Get-Help about_Script_Blocks

在angularjs官方文件中,没有关于提供指令的描述。只需在Error: [$injector:unpr] Unknown provider: myComponentDirectiveProvider <- myComponentDirective添加到组件。

我认为指令是由angularjs中的.component方法提供的。 对于组件,我认为没有必要提供。

如何修复此错误?请给我建议。

我的代码如下。

component.ts

.directive

app.ts

/// <reference path="../../require.d.ts" />

export class MyController {
  name: string;
  age: number;

  $onInit(): void {
  }
}

export let myComponent = {
  template: require('./index.html'),
  controller: MyController,
  bindings: {
    name: "@",
    age: "@",
  }
}

component.spec.ts

import * as angular from 'angular';

import { myComponent } from './component/index';

angular.module('myApp', []);

angular.module('myApp')
  .component('myComponent', myComponent);

0 个答案:

没有答案
相关问题