0

Posting this GitHub issue.

I want to set up an excel add-in using angular for the taskpane and which also includes ribbon commands and custom functions. I have an existing add-in which does not use angular and includes custom functions and ribbon commands.

How can I "hook" into the angular app from "outside" of it, namely from custom functions (or ribbon commands)? The angular app is bootstrapped from Office.onReady but there's no equivalent for custom functions. I can't just import {ThingService} from "../services" and const thingService = new ThingService() if there are dependencies. That wouldn't include things like interceptors which would add the auth header or error handling.

I can't just import and instantiate my service class from angular, I want to re-use everything I've set up.

Would using events make sense, if the angular app was set up to listen to them on the window object?

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
celluj34
  • 11
  • 1

1 Answers1

0

If you use a shared runtime for the custom functions and the task pane, then anything loaded in the task pane is available in the custom function too, including a service object.

Rick Kirkham
  • 9,038
  • 1
  • 14
  • 32
  • Right, and that's what I want, but the custom functions aren't invoked within angular's context, which is part I'm trying to solve. – celluj34 Apr 05 '23 at 19:02
  • It's not clear to me what you mean by "within angular's context" or why the custom function needs to be invoked within it. As I understand it you have a backend service that serves up data. You have an angular ThingService that kind of wraps, and calls out to, the backend service in some way, such as with HTML requests if it is a REST-based service. Why can't the custom function make calls to that backend service directly? – Rick Kirkham Apr 06 '23 at 03:59
  • The reason I want the custom functions to be invoked within is because I want to be able to re-use thing like interceptors and dependencies required by any service. Since the invocation of a custom function happens outside of angular, if I were to just instantiate my ThingService directly, I would lose those dependencies. I _could_ call the backend service directly, but then I would be duplicating all of my service logic twice - once for angular and once for custom functions. – celluj34 Apr 06 '23 at 14:09