0

i had problem when i use F5 button or directive call url from address bar ngOnInit not called properly.. I'm using debugger to see what happen, and the problem is callHook not triggered after ngOnInit..

I'm using Angular 9.1.2

This is my ngOnInit

ngOnInit(): void {
    console.log('fired OnInit');
    
    this.dtOptions = {
      pagingType : 'full_numbers',
      pageLength : 10
    };
    this.getCurrentUser();
    this.initializeList();
    this.resetFormData();
  }

and i'm using Ngx-Soap for call database, here's my service

import { Injectable } from '@angular/core';
import { Client, ISoapMethodResponse, NgxSoapService } from 'ngx-soap';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { Document } from '../_models/document.model';
import { User } from '../_models/user.model';

@Injectable({
  providedIn: 'root'
})
export class GeneralService {
  client : Client;
  xmlResponse : string;
  jsonResponse : string;
  resultLabel : string;

  constructor(
    private soap : NgxSoapService
  ) {
    this.soap.createClient(environment.wsURL).then(client=>{
      client.addSoapHeader({
        'tns:ModuleCredential':{
          'tns:ModuleAppName':'xxxx',
          'tns:ModuleUserName':'xxxx',
          'tns:ModulePassword':'xxxx'
        }  
      });
      client.addHttpHeader(
        'Content-Type','text/xml; charset=utf-8'
      );
      this.client = client;
    })
    .catch(err=>console.log('SoapError',err))
   }

  Login(formData : User) : Observable<ISoapMethodResponse>{
    const body = {
      data : formData
    };    
    return this.client.call('Login',body)
  }

  GetCategoryList():Observable<ISoapMethodResponse>{
    const body ={
      data:null
    };
    return this.client.call('GetCategoryList',body);
  }  

this is my image from Debugger, and those 3 yellow not called after ngOnInit

this is my console result

lucky.omen
  • 15
  • 4
  • It sounds like `ngOnInit()` is firing, but how what isn't working that should happen in those `callHook`s? – Levidps Dec 07 '20 at 04:46
  • ```callHooks``` is skipped after ```ngOnInit()``` is firing, so ```refreshView``` will do ```leaveView()``` because ```callHooks``` not detected any changes – lucky.omen Dec 07 '20 at 04:51
  • It sounds like there's potentially something weird with the project/components. If you had a working example in stackblitz it would be easier to suss out what the issue is. – Levidps Dec 07 '20 at 05:04

2 Answers2

0

Show what error the Chrome DevTools console gives you.

0

After searching for awhile and test everything, so the answer is back to NgxSoap, the constructor of service not triggered and cause this error.. Still looking why this constructor not triggered at NgxSoap github.. Thanks all..

lucky.omen
  • 15
  • 4