我得到了类型错误,“期望0类型参数,但得到1”,尽管遵循本教程到T。https://youtu.be/I317BhehZKM?t=57s
我已指定:
newUserInfoComplete:boolean = false
然而,我在这行代码中得到了上面在<boolean>
上指定的错误:
@Output() newUserInfoCompleteEvent = new EventEmitter <boolean> ();
另外,如果我简单地忽略<boolean>
,我会得到这个错误:
Argument of type 'boolean' is not assignable to parameter of type 'string'.
这个.NewUserInfoComplete在这里加了下划线:
this.newUserInfoCompleteEvent.emit(this.newUserInfoComplete);
下面是我的组件:
import { Component, OnInit, Output } from '@angular/core';
import { slideToRight } from '../../../../router.animations';
import { Router, ActivatedRoute, UrlSegment } from '@angular/router';
import { EventEmitter } from 'protractor';
@Component({
selector: 'app-new-user-input',
templateUrl: './new-user-input.component.html',
styleUrls: ['./new-user-input.component.css'],
animations: [slideToRight()]
})
export class NewUserInputComponent implements OnInit {
newUserInfoComplete:boolean = false
@Output() newUserInfoCompleteEvent = new EventEmitter <boolean> ();
constructor(private router: Router, r: ActivatedRoute) {
r.url.subscribe((s: UrlSegment[]) => {
console.log("url", s); //https://vsavkin.com/angular-router-understanding-router-state-7b5b95a12eab
});
}
ngOnInit() {
}
sendNewUserInfoComplete(){
this.newUserInfoCompleteEvent.emit(this.newUserInfoComplete);
}
displaySibling() {
console.log(this.router);
this.router.navigate(['../', { outlets: { newuserorginfo: ['newuserorginfo'] } }])
}
closeBlade() {
this.router.navigate([{ outlets: { newuserinput: null } }]);
}
}
4条答案
按热度按时间jmp7cifd1#
尝试从
@angualar/core
而不是从protractor
导入EventEmitter
:wfveoks02#
我忘了检查我的进口!糟糕,我用的是PROTRACTOR的事件发射器,而不是角核事件发射器
1mrurvl13#
正如上面的答案中提到的,不要从'*protractor '导入
EventEmitter
,而是从'@angular/core *'导入。为什么会发生:因为你在导入它之前使用了
EventEmmiter
,所以在这种情况下它会自动从'protractor'模块导入。bjp0bcyl4#
试试这个