search

Home  >  Q&A  >  body text

javascript - How to create an object in angular whose properties and methods can be accessed by components in different modules

The properties and methods of this object need to be accessible to components in any module

習慣沉默習慣沉默2700 days ago911

reply all(5)I'll reply

  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-06-26 10:56:24

    Simply create the corresponding component in ShareModule.

    reply
    0
  • 世界只因有你

    世界只因有你2017-06-26 10:56:24

    Use the service, please note that the service must be registered in the root module

    reply
    0
  • ringa_lee

    ringa_lee2017-06-26 10:56:24

    You can use services or local storage

    reply
    0
  • ringa_lee

    ringa_lee2017-06-26 10:56:24

    It’s more convenient to use the service.

    reply
    0
  • typecho

    typecho2017-06-26 10:56:24

    Use the run method to define a $rootScope.aa = 1; then you can get $rootScope.aa from other places

    reply
    0
  • Cancelreply