1

I want to push a provider to my list of providers only if browser is IE.

I tried like

 const IE = detectIE();
    providers: [abcService,
      xyzService,
      (IE) ? [{provide: EVENT_MANAGER_PLUGINS,
        useClass: IeInputEventManagerService,
        deps: [DOCUMENT],
        multi: true
    }] : [],

The above code throws AOT error saying symbols not allowed in decorator. I tried like below also

const IE = detectIE();
const tempProviders: Array<any> = [
  abcService,
  xyzService];

if(IE) {
tempProviders.push({provide: EVENT_MANAGER_PLUGINS,
    useClass: IeInputEventManagerService,
    deps: [DOCUMENT],
    multi: true
});
}

@NgModule -> continues here

In above case, the provider never gets pushed or never gets active. How do i solve this issue?

Hacker
  • 7,798
  • 19
  • 84
  • 154
  • I had this issue recently, I didn't have time to fix and just remove the inline if - however, the error seemed to be coming from the condition - How do you determine the value for IE? Can you give a full stack trace? – danday74 Aug 07 '18 at 21:17
  • Updated my code above. IE is a variable determined by function call. Yup error is triggered from the if condition. But how do i over come it. – Hacker Aug 08 '18 at 03:28
  • can you resolve IE without calling a function - I had the same error re: the function call issue when I was calling a lodash function – danday74 Aug 08 '18 at 04:50
  • Nope. Without function its difficult to resolve IE, as i need to detect different version of IE. – Hacker Aug 08 '18 at 05:54

0 Answers0