How to run a service when the app starts in Angular 2

前端 未结 4 1212
暗喜
暗喜 2020-12-12 15:50

I created a service SocketService, basically it initializes the socket to let the app listen on the port. This service also interacts with some components.

/

4条回答
  •  被撕碎了的回忆
    2020-12-12 16:03

    Also see APP_INITIALIZER, which is described as;

    A function that will be executed when an application is initialized.

提交回复
热议问题