How, Why, and When to Use Providers in Ionic
HTML-код
- Опубликовано: 1 окт 2024
- In this video tutorial, I walk through a simple of example of when it would make sense to create a provider in Ionic and how to do it.
Blog post: www.joshmorony...
Learn Ionic: www.joshmorony...
Nice tutorials, could you do an ionic 2 offline first tutorial?
Excellent work! Showing the first way without a provider and then refactoring to use a provider made it very clear why a provider is a good idea. I also expect using a provider will make testing easier as well. Based on this I have purchased your ebook package. Thank you.
I really enjoy your videos. Thank you for the helpful tutorials! :)
You're welcome :)
How can I use providers in ionic 6?
i don't like directly using the service in the template, why not create a page component local variable and assign to it the load() result.
It depends on the context but in general, I prefer accessing through the provider directly, it can make the code a lot simpler. For example, if I assigned the result of the load method to a variable in the page, and then later update add or delete some item, I need to make sure I update the local reference in the page as well (perhaps directly or I could have an observable set up). If the template is accessing the provider directly then you don't need to worry about any of that, as soon as the provider updates the template will.
I was about to ask the same question, Nice answer Josh. I see your point. All this time I was following what khocef is doing.
Thanks a lot for the nice tutorials, they are really helpful :)
cheers
Thank you so much, well made videos (with actual explanations, not just do A then do B) about Ionic are kinda rare
Thanks for this Great tutorial Josh, One Issue the data i passes to second page log Undefined. I'm i doing something wrong?
Very good tutorial. Consider doing an example with SQLite
Hi Joshua, how do you generate indexed suffixes for post variable? Is it a sublime plugin or a native tool from sublime?
Very helpful explaining "why" to use a provider AND showing how. Thanks for the great tutorial!
thanks very much , its working for me :)
Thanks Josh for another very helpful video. I really need to start moving the heavy lifting code out of my page classes.
Good work. Thank you
Uncaught (in promise): Error: No provider for Http!
Error
at Error (native)
at g (localhost:8100/build/polyfills.js:3:7133)
at injectionError (localhost:8100/build/main.js:1511:86)
at noProviderError (localhost:8100/build/main.js:1549:12)
at ReflectiveInjector_._throwOrNull (localhost:8100/build/main.js:3051:19)
at ReflectiveInjector_._getByKeyDefault (localhost:8100/build/main.js:3090:25)
at ReflectiveInjector_._getByKey (localhost:8100/build/main.js:3022:25)
at ReflectiveInjector_.get (localhost:8100/build/main.js:2891:21)
at NgModuleInjector.get (localhost:8100/build/main.js:3856:52)
at resolveDep (localhost:8100/build/main.js:11260:45)
at createClass (localhost:8100/build/main.js:11117:35)
at _createProviderInstance (localhost:8100/build/main.js:11086:17)
at createProviderInstance (localhost:8100/build/main.js:10927:64)
at createViewNodes (localhost:8100/build/main.js:12293:49)
at createRootView (localhost:8100/build/main.js:12208:5)
Have you removed the Http provider from the constructor?
محمد شعلانBut what if I need to use the http provider in the Posts provider ?! Why do we have to remove it to work !?
you can have both, but you need to import http the proper way before using it, otherwise u will get the same err.
So how should I import http in a provider ?!
Joshua congratulations!!
It would be great a bit of FireBase
a big hug
how to check all field is empty in login from using ionic 2?
please tell me.
Nice
hello, how can u access the post variable in app.html
Thank you so much Josh
Thank You good tutorial
Thank you good video!
thanks, this helped me.