(Angular 7)无法在ng-block-ui上分配为只读属性'isActive'

时间:2019-05-20 06:45:34

标签: angular

我正在尝试对我的项目使用ng-block-ui依赖项。问题是它在Angular 7上无法正常工作。我已经在Angular 6项目中使用了它,并且工作正常

app.module.ts

import { BlockUIModule } from 'ng-block-ui';


@NgModule({
     BlockUIModule.forRoot()
})

component.ts

import { BlockUI, NgBlockUI } from 'ng-block-ui';

export class *classname* implements OnInit {
     @BlockUI('departure') blockUIList: NgBlockUI;

     constructor() { this.blockUIList.start('Loading Page...'); }
}

component.html

<div class="kt-portlet kt-portlet--mobile" *blockUI="'departure'">

错误消息

ERROR TypeError: Cannot assign to read only property 'isActive' of object '[object Object]'
    at BlockUIInstanceService.push../node_modules/ng-block-ui/fesm5/ng-block-ui.js.BlockUIInstanceService.blockUIMiddleware (ng-block-ui.js:113)
    at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:192)
    at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:130)
    at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:76)
    at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:53)
    at ReplaySubject.push../node_modules/rxjs/_esm5/internal/Subject.js.Subject.next (Subject.js:47)
    at ReplaySubject.push../node_modules/rxjs/_esm5/internal/ReplaySubject.js.ReplaySubject.nextInfiniteTimeWindow (ReplaySubject.js:39)
    at Object.stop (ng-block-ui.js:131)
    at SafeSubscriber._complete (booking-reservation.component.ts:125)
    at SafeSubscriber.wrappedComplete (Subscriber.js:175)

1 个答案:

答案 0 :(得分:1)

我对此有疑问。

从ng-block-ui中的fesm5 / ng-block-ui.js中更改isActive = true时,我出错了。

这不是一个完美的解决方案,ng-block-ui.js->行:114 [this.blockUIInstances [name] .isActive = isActive] ==> this.blockUIInstances [name] = Object.assign({},这。 blockUIInstances [name],{isActive:isActive}),则可以修复它而不会出错。