Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70439

Ionic4: How to use a Service Provider as a singleton?

$
0
0

@ioclaudio wrote:

Hi,
I’d like to create a service provider "QrcodemanagerService " and use it in all the pages of the application as a singleton.
My doubt is this:

If I define the service provider in this way:

@Injectable({
  providedIn: 'root'
})
export class QrcodemanagerService {...}

Is still necessary to add it to the constructor of each page?

  constructor(private navController: NavController,
              private statusManager: StatusmanagerService) {...}

Or, since I’ve added providedIn: ‘root’ in the definition, I can use it without including it in the constructor of the page?
If yes, how can I refer in a page to this sigleton?

thank you

Claudio

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70439

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>