0
我想测试一个角度为1.5的组件,但是Typescript在控制台中投入红色。
(17,27):错误TS2349:无法调用其类型缺少呼叫签名的表达式。类型'IComponentOptions'没有兼容的呼叫签名。 PhantomJS 2.1.1(Windows 8的0.0.0)组件:RecipeContainer应该有一个定义的组件失败
我是否正确,包括文件? (我正在使用webpack进行编译)。
我是否缺少类型定义?
任何帮助,将不胜感激,一直挠我的头几个小时了。
spec文件:
import * as angular from 'angular';
import 'angular-mocks';
import { RecipeContainer } from './recipe-container.component';
import { recipes } from '../recipe-store';
describe('Component: RecipeContainer',() => {
let $componentController: ng.IComponentOptions;
beforeEach(angular.mock.module('app'));
beforeEach(angular.mock.inject((_$componentController_: ng.IComponentOptions) => {
$componentController = _$componentController_;
}));
it('should have a defined component',() => {
const bindings = { recipes };
const component = $componentController('RecipeContainer', null, bindings); //webstorm underlines this line
expect(component).toBeDefined();
});
});
component.ts:
class RecipeContainerController implements ng.IComponentController {
constructor(private $log: ng.ILogService) {
}
$onInit() {
this.$log.info('inside onInit');
}
}
export const RecipeContainer: ng.IComponentOptions = {
bindings: {
recipes: '<'
},
controller: RecipeContainerController,
template: '<div>hello</div>'
};