我得到类型错误,“预期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'.
和this.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 } }]);
}
}
答案 0 :(得分:54)
尝试从Angular而不是SELECT CAST(XDate AS DATE) as 'TheDate', SUM (TheCount) as count
FROM TheTable
WHERE XDate >= '4/1/2018' AND XDate < '5/1/2018'
GROUP BY CAST(XDate AS DATE), TheCount
导入EventEmitter
:
protractor
答案 1 :(得分:2)
请勿从'量角器'导入EventEmitter
,而从' @ angular / core '导入。
发生原因的原因:因为您在导入之前使用了EventEmmiter
,所以在这种情况下,它会自动从“ 量角器”模块中导入。
答案 2 :(得分:1)
import { Component, 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 {
newUserInfoComplete = false;
@Output() newUserInfoCompleteEvent = new EventEmitter <boolean> ();
constructor(private router: Router, r: ActivatedRoute) {
r.url.subscribe((s: UrlSegment[]) => {
console.log("url", s);
});
}
sendNewUserInfoComplete(){
this.newUserInfoCompleteEvent.emit(!!this.newUserInfoComplete);
}
displaySibling() {
console.log(this.router);
this.router.navigate(['../', { outlets: { newuserorginfo: ['newuserorginfo'] } }])
}
closeBlade() {
this.router.navigate([{ outlets: { newuserinput: null } }]);
}
}
试试这个
答案 3 :(得分:1)
我忘记检查我的进口了!该死。我使用的是PROTRACTOR'S事件发射器而不是角度核心事件发射器
import { EventEmitter } from '@angular/core';
import { Component, OnInit, Output } from '@angular/core';
import { slideToRight } from '../../../../router.animations';
import { Router, ActivatedRoute, UrlSegment } from '@angular/router';
@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 = 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 :(得分:0)
您只是导入错误,从@ angular / core导入,一切都很好
答案 5 :(得分:0)
import { EventEmitter, Component, OnInit, Output } from '@angular/core';
请确保在EventEmitter
上导入@angular/core
,否则会出错。
我误会了。我正在导入-
import { EventEmitter } from 'events';
因此获取错误
答案 6 :(得分:0)
不导入以下事件:
import { EventEmitter } from 'events';
尝试如下所示导入:
import { EventEmitter } from
'@angular/core';
答案 7 :(得分:0)
只需替换自动添加的导入语句:
import * as EventEmitter from 'events';
与
import { Component, OnInit, Output ,EventEmitter} from '@angular/core';