Angular 10:从其他组件执行单击功能时出现服务未定义错误

问题描述

我面临服务未定义错误。我正在从共享组件执行单击功能,然后,我调用一个服务,但该服务在组件中显示为未定义。 我也在 app 模块和提供者中添加了服务。尽管如此,我仍然面临这个问题。任何人都可以帮我解决这个问题。

方法

py4j.protocol.Py4JJavaError: An error occurred while calling 
z:org.apache.spark.api.python.PythonRDD.saveAsNewAPIHadoopFile.
: java.lang.classNotFoundException: com.mongodb.hadoop.io.BSONWritable

点击共享组件中的组件html:

approveReject(data,action,type){
    
    console.log(data,type);

    let endpoint;
    let reqData;
    if( type.toLowerCase() == 'advertiser'){
      if(action.toLowerCase() == 'approve'){
        endpoint = 'advActivate';       
      }else{
        endpoint = 'advReject';
      }
      reqData = {         
        guid:data.guid,userid:data.userid,id:data.id,}
      
    }else if(type.toLowerCase() == 'publisher'){
      if(action.toLowerCase() == 'approve'){
        endpoint = 'pubActivate';
      }else{
        endpoint = 'pubReject';
      }
    }
    console.log('**********');
    console.log(this.apiservice);
   
    this.apiservice.fullLoader(true);
    this.apiservice.post(endpoint,reqData).subscribe((res) => {
      this.apiservice.fullLoader(false)
        console.log("res->",res)
        if(res.msg.toLowerCase() == 'ok' && res.error_code == 0){
          this.apiservice.alertMessage('success',type.toLowerCase()+''+action.toLowerCase()+'ed  Successfully');
        }
    },err => {
      this.apiservice.fullLoader(false)
      this.apiservice.alertMessage('danger','Failed to '+action.toLowerCase()+''+type.toLowerCase()+'Please Try again');
    })
   
  }

错误

<ng-template pTemplate="body" let-data let-columns="columns">
    <tr>
        <td *ngFor="let col of columns">
            <ng-container *ngIf="col.field != 'actions';else alink">
                {{data[col.field]}}
            </ng-container>
                
            <ng-container *ngIf="col.field == 'actions'" #alink>
                
                <a  *ngFor="let linkData of data[col.field]" href="javascript:;"  title="{{linkData.name}}" [appHasRole]="linkData.hasRole" (click)="linkData.action(data,linkData.name,linkData.type)"><i class="{{linkData.icon}}"></i>                    
                </a>
            </ng-container>
        </td>       
    </tr>
   </ng-template>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)