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...

Комментарии • 29

  • @obeydadjeffal4442
    @obeydadjeffal4442 7 лет назад +5

    Nice tutorials, could you do an ionic 2 offline first tutorial?

  • @andydorman4695
    @andydorman4695 7 лет назад +1

    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.

  • @Mr_BetaMax
    @Mr_BetaMax 7 лет назад +2

    I really enjoy your videos. Thank you for the helpful tutorials! :)

  • @reneramirez412
    @reneramirez412 3 года назад

    How can I use providers in ionic 6?

  • @moncefkho
    @moncefkho 7 лет назад +2

    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.

    • @JoshuaMorony
      @JoshuaMorony  7 лет назад

      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.

    • @sameeragayan9092
      @sameeragayan9092 7 лет назад

      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

  • @FieelFlying
    @FieelFlying 6 лет назад

    Thank you so much, well made videos (with actual explanations, not just do A then do B) about Ionic are kinda rare

  • @yusadolat
    @yusadolat 7 лет назад

    Thanks for this Great tutorial Josh, One Issue the data i passes to second page log Undefined. I'm i doing something wrong?

  • @AnthonyRamtulla
    @AnthonyRamtulla 6 лет назад

    Very good tutorial. Consider doing an example with SQLite

  • @pedrodurek
    @pedrodurek 7 лет назад

    Hi Joshua, how do you generate indexed suffixes for post variable? Is it a sublime plugin or a native tool from sublime?

  • @markellis7712
    @markellis7712 7 лет назад

    Very helpful explaining "why" to use a provider AND showing how. Thanks for the great tutorial!

  • @entertainmentstudying1617
    @entertainmentstudying1617 6 лет назад

    thanks very much , its working for me :)

  • @NormGlomski
    @NormGlomski 7 лет назад

    Thanks Josh for another very helpful video. I really need to start moving the heavy lifting code out of my page classes.

  • @vishnurapposol4698
    @vishnurapposol4698 7 лет назад +1

    Good work. Thank you

  • @paulonelsonm
    @paulonelsonm 7 лет назад

    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)

    • @mohammedalshaalan6957
      @mohammedalshaalan6957 7 лет назад

      Have you removed the Http provider from the constructor?

    • @michaelibrahim8360
      @michaelibrahim8360 7 лет назад

      محمد شعلانBut what if I need to use the http provider in the Posts provider ?! Why do we have to remove it to work !?

    • @mohammedalshaalan6957
      @mohammedalshaalan6957 7 лет назад

      you can have both, but you need to import http the proper way before using it, otherwise u will get the same err.

    • @michaelibrahim8360
      @michaelibrahim8360 7 лет назад

      So how should I import http in a provider ?!

  • @laurisilva4092
    @laurisilva4092 7 лет назад

    Joshua congratulations!!
    It would be great a bit of FireBase
    a big hug

  • @kanagavel3121
    @kanagavel3121 7 лет назад

    how to check all field is empty in login from using ionic 2?
    please tell me.

  • @kejianxin9735
    @kejianxin9735 7 лет назад +1

    Nice

  • @emmanuelogoma2595
    @emmanuelogoma2595 7 лет назад

    hello, how can u access the post variable in app.html

  • @brianivandertp
    @brianivandertp 5 лет назад

    Thank you so much Josh

  • @saidelghamri2947
    @saidelghamri2947 6 лет назад

    Thank You good tutorial

  • @manukorn5823
    @manukorn5823 6 лет назад

    Thank you good video!

  • @marcusviniciussilvaoliveir1533
    @marcusviniciussilvaoliveir1533 6 лет назад

    thanks, this helped me.