首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法读取未定义的角度8的属性实例

无法读取未定义的角度8的属性实例
EN

Stack Overflow用户
提问于 2021-09-03 12:41:37
回答 1查看 282关注 0票数 0

我有一个模式,在其中我会使用一个组件(ngx- image-cropper ),但每次在image-cropper上“无法读取未定义的属性实例”时,我都会得到这个错误。

Preview()调用成功,this.logoToUpload工作正常,问题是使用图像裁剪器组件打开模式,否则模式也工作正常。

下面是我的代码:

代码语言:javascript
复制
import { ImageCroppedEvent, LoadedImage } from 'ngx-image-cropper';

@Component({
  selector: 'logo',
  templateUrl: './logo.component.html',
  styleUrls: ['./logo.component.scss']
})
export class LogoComponent implements OnInit {

constructor(
    private modalService: NgbModal,
  ) {}

ngOnInit() {}

preview(content) {
    var mimeType = this.logoToUpload.type;
    if (mimeType.match(/image\/*/) == null) {
      return;
    }
    debugger;
    // Show preview
    this.modalService.open(content).result.then(
      (result) => {
        //DO SOMETHING IN CASE RESULT IS SAVE OR NOT
      }, (reason) => {
    });
}

HTML:

代码语言:javascript
复制
<ng-template #modalCroppingImage let-modal>
  <div class="modal-header modal-header-new">
    Select area
  </div>
  <div class="modal-body">
   <image-cropper [imageFile]="logoToUpload"
                   [maintainAspectRatio]="true"
                   [aspectRatio]="4 / 3"
                   format="png"
                   (imageCropped)="imageCropped($event)"
                   (imageLoaded)="imageLoaded()"
                   (cropperReady)="cropperReady()"
                   (loadImageFailed)="loadImageFailed()"></image-cropper>
  </div>
  <div>
    <button type="button" class="btn btn-primary button-modal-detail-new" (click)="modal.close('Save'); resetView();">SAVE<!--Close--></button>
    <button type="button" class="btn btn-primary button-modal-detail-new" (click)="modal.close('Close'); resetView();">CLOSE<!--Close--></button>
    </div>
</ng-template>

编辑:我也得到了这个错误:

StaticInjectorError(AppModule)ImageCropperComponent -> CropService: StaticInjectorError(Platform: core)ImageCropperComponent -> CropService: NullInjectorError:不提供CropService!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-03 15:49:00

我发现了这个问题,Angular 8不再支持ngx-image-cropper。如果你有同样的问题,你必须安装3.3.5版本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69045150

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档