我正在注入$timeout
以下指令,但未定义。
以下代码将undefined打印到控制台并抛出TypeError: $timeout is not a function ;
export default class foo {
constructor ($timeout) {
'ngInject';
this.restrict = 'A';
this.scope = {};
this.$timeout = $timeout;
console.log( $timeout );
$timeout( function() {
alert('timeout');
}, 0 );
}
link($scope, $element, $attrs, $ctrl ) {
....
}
// Create an instance so that we can access this inside link
static factory() {
foo.instance = new foo();
return foo.instance;
}
}