我想要做的是从另一个组件打开一个模态,但是TypeError: Cannot create property 'validator' on string 'test1'
当component1.html
加载因为childModal
包含时我不断收到此错误.如何摆脱这些错误并正确实施?
component1.html
<button type="button" class="btn btn-outline-primary btn-lg" (click)="modal.showModal()">Test
......
<child-modal #childModal ></child-modal>
Run Code Online (Sandbox Code Playgroud)
component1.ts
@ViewChild('childModal') childModal: ModalComponent;
Run Code Online (Sandbox Code Playgroud)
modal.html
<div bsModal #childModal="bs-modal" class="modal fade" tabindex="-1" role="dialog>
<div class="modal-dialog modal-lg">
<div class="modal-content">
<input type="text" formControl="test1">
<input type="text" formControl="test2">
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
modal.component.ts
constructor(private modalService: BsModalService) {
this.form = new FormGroup({
'test': new FormControl(),
'test2': new FormControl()
})
}
Run Code Online (Sandbox Code Playgroud) 我有一个倒数计时器,在用户离开页面后继续运行.当用户离开页面时,我想要销毁倒数计时器或停止它.我怎样才能做到这一点?
countdown.ts
public time: number;
public countDown:Observable<any>;
public currentUnix;
constructor() {
this.currentUnix = moment().unix();
this.time = moment(1503773977000).unix() - this.currentUnix;
}
ngOnInit() {
this.countDown = Observable.interval(1000)
.map(res => {
return this.time = this.time - 1
})
.map(res => {
let timeLeft = moment.duration(res, 'seconds');
let string: string = '';
// Days.
if (timeLeft.days() > 0)
string += timeLeft.days() + ' Days';
// Hours.
if (timeLeft.hours() > 0)
string += ' ' + timeLeft.hours() + ' Hours';
// Minutes.
if (timeLeft.minutes() > …
Run Code Online (Sandbox Code Playgroud) 我从另一个组件调用一个模态,问题是我只能将它打开为小而不是大
comp1.html
<button type="button" class="btn btn-outline-primary btn-lg" (click)="openModal()">Upload
Run Code Online (Sandbox Code Playgroud)
comp1.ts
import {modalComponent} from '../pages/modals/new-modal';
private modalService: BsModalService
constructor(private modalService: BsModalService)
openModal() {
this.bsModalRef = this.modalService.show(modalComponent);
}
Run Code Online (Sandbox Code Playgroud)
modal.component.ts
constructor(private modalService: BsModalService, public bsModalRef: BsModalRef)
Run Code Online (Sandbox Code Playgroud)
modal.html
<div bsModal #newModal="bs-modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我Angular 5
和RXJS 5.5一起使用
在我做这样的事情之前
getProjectInfo(id): Observable<any> {
const URL = `${this.API}/${id}`;
return this.http.get(URL)
.pipe(map(res => res)),
catchError(this.handleServerError);
}
handleServerError(error: any) {
console.log(error.error || error.json() || error);
return Observable.throw(error.error || error.json() || error || 'Server error');
}
Run Code Online (Sandbox Code Playgroud)
但现在我收到了这个错误
Error:(21, 5) TS2322:Type 'UnaryFunction<Observable<{}>, Observable<any>>' is not assignable to type 'Observable<any>'.
Property '_isScalar' is missing in type 'UnaryFunction<Observable<{}>, Observable<any>>'.
Run Code Online (Sandbox Code Playgroud)
我也试过这个
getProjectInfo(id): Observable<any> {
const URL = `${this.API}/${id}`;
return this.http.get(URL)
.pipe(map(res => res)),
catchError(err => this.handleError('getProjInfo', URL));
}
private handleError(method: String, URL: …
Run Code Online (Sandbox Code Playgroud) I want to display the error message in a bootstrap alert. I'm using angular2 as my frontend and lumen as my backend.
Frontend
<div class="alert alert-danger">
// Display error message here
</div>
Run Code Online (Sandbox Code Playgroud)
I want the response from the validate function displayed on the frontend
public function uploadImage(Request $request)
{
$this->validate($request, [
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:60000',
]);
}
Run Code Online (Sandbox Code Playgroud)
component.ts
uploadFile(): void {
let file = this.fileInput.nativeElement;
if (file.files && file.files[0]) {
let fileToUpload = file.files[0];
this.getInfoService
.uploadImage(fileToUpload)
.subscribe(
data => console.log("DATA", data), …
Run Code Online (Sandbox Code Playgroud) 我SET sql_mode = ''
在尝试禁用ONLY_FULL_GROUP_BY
重置当前启用的所有模式时不小心做了。如何恢复到默认设置?我在MySQL 5.7.20
Homestead Vagrant 盒子上运行。
谢谢