我正在尝试创建一个功能,用户可以在其中将图片粘贴到页面上,我可以将其上传到服务器并显示给用户。
我知道粘贴事件,并试图从那里实现,但无法从事件中访问剪贴板中的任何数据,事件的剪贴板字段中的文件或项目数组始终为空,当我按 ctrl + v。
这是代码:
<div (paste)="pastePicture($event)" style="height: 300px; width: 300px; background-color:#ccc;">
</div>
pastePicture(event: ClipboardEvent) {
console.log(event); }
Run Code Online (Sandbox Code Playgroud)
https://plnkr.co/edit/QmELBtWJqjAuEwGPiCZh?p=preview
对此有何想法?
我正在尝试为这些步骤实现这种设计,但到目前为止还没有成功,我得到的最接近的是为当前活动步骤旁边的行赋予颜色:
.mat-horizontal-stepper-header {
padding: 0 8px 0 16px !important;
&[ng-reflect-active="true"]+.mat-stepper-horizontal-line {
border-top-color: rgba(37, 82, 245, 0.54) !important;
}
Run Code Online (Sandbox Code Playgroud)
}
但目的是为活动步骤的前一行着色,如图所示。
对此有何想法?这是一个用于复制的 stackblitz https://stackblitz.com/edit/angular-ngcsei
在对话响应的条件下,我对注销确认有这种效果,但出现以下错误:
错误错误:效果“AuthEffects.logoutConfirmation$”调度了一个无效的动作:未定义
和
错误类型错误:操作必须是对象
效果如下:
@Effect()
logoutConfirmation$ = this.actions$
.ofType<Logout>(AuthActionTypes.Logout)
.pipe(
map(action => {
if (action.confirmationDialog) {
this.dialogService
.open(LogoutPromptComponent)
.afterClosed()
.pipe(
map(confirmed => {
if (confirmed) {
return new LogoutConfirmed();
} else {
return new LogoutCancelled();
}
})
);
} else {
return new LogoutConfirmed();
}
})
);
Run Code Online (Sandbox Code Playgroud)
它在激活确认对话框时起作用,我想这是对话框响应的地图有问题,一直试图理解它但找不到方法。任何人都有这方面的线索?
编译我的应用程序时,我一直收到此错误.TS v2.0.3
app/components/profile.component.ts(13,12): error TS1005: '=' expected.
app/components/profile.component.ts(14,13): error TS1005: '=' expected.
app/components/profile.component.ts(16,10): error TS1005: '=' expected.
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
import { Component } from '@angular/core';
import { apiService } from '../services/api.service';
import 'rxjs/add/operator/map';
@Component({
moduleId: module.id,
selector: 'profile',
templateUrl: './profile.component.html'
})
export class ProfileComponent{
product[];
products[];
productTitle:string;
first[];
constructor(private _apiService:apiService){
this._apiService.getProduct().subscribe(product => {
//console.log(product.result.products);
this.product = product.result.products[0];
})
}
searchProd() {
this._apiService.updateTitle(this.productTitle);
this._apiService.getProduct().subscribe(productTitle => {
//console.log(productTitle.result.products);
this.first = productTitle.result.products[0];
this.products = productTitle.result.products;
})
}
}
Run Code Online (Sandbox Code Playgroud)
我读过它可能是因为TS的更新语法,并将其更新到最新的2.1.0版本,但仍然出现错误.
有人可以帮我吗?