微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。