Using Custom Components on Multiple Pages in Ionic

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ต.ค. 2024

ความคิดเห็น • 158

  • @nirliptgaur
    @nirliptgaur 5 ปีที่แล้ว +5

    Just another Thank You message among the above millions. I am teaching ionic 4 to some interns and your videos give them clarity. I just love the way you first take a normal approach, and then when the error pops up, like it does for us, you show the actual way things need to be coded. Excellent Effort. Hope Ionic Team hires you :P

  • @gianlucacau5907
    @gianlucacau5907 4 ปีที่แล้ว +4

    You just saved me a lot of time that would have been wasted! Thanks man, speaking of Ionic you sure are the best!

  • @simonsutherland15
    @simonsutherland15 4 ปีที่แล้ว

    I was going around in circles, reading and re-reading documentation & examples (mostly of non-lazy loaded components) No i not only know what to do, but _why_ This was a life saver!

  • @denisgarcia01
    @denisgarcia01 5 ปีที่แล้ว

    Thanks. The main fix for me was the explanation about the lazy loading not loading components. That made my day. Thank you!

  • @sergijonama1748
    @sergijonama1748 5 ปีที่แล้ว +6

    Nice tutorial thanks!
    In Ionic 4 you should add some extra imports to avoid template parse errors.
    import { SyncIconComponent } from './sync-icon/sync-icon.component';
    import { NgModule } from '@angular/core';
    import { CommonModule } from '@angular/common';
    import { IonicModule } from '@ionic/angular';
    @NgModule({
    imports: [CommonModule, IonicModule],

    • @acarolsfs
      @acarolsfs 4 ปีที่แล้ว +2

      Thanks man! You saved my life

    • @oswaldkit
      @oswaldkit 4 ปีที่แล้ว +2

      Thanks man! You saved my life too.

    • @buraksimsek2471
      @buraksimsek2471 2 ปีที่แล้ว

      Thanks man! You saved my life too. By the way, I encountered this in Ionic 6.

    • @f1234411231
      @f1234411231 ปีที่แล้ว

      Thanks man! You saved my life too.

  • @muhammadshahrez2130
    @muhammadshahrez2130 5 ปีที่แล้ว

    Thank God I found you at the right time. I was banging my head figuring out what was wrong with my component and you litterally saved me from a nightmare.

  • @tendaikatsande7578
    @tendaikatsande7578 4 ปีที่แล้ว

    You saved my life, I had to also add other modules, like ionicModule, RoutingMoudle to the shared module

  • @Iam_AndersonP
    @Iam_AndersonP 2 ปีที่แล้ว

    Grat tutorial.
    Another thing in cosideration is that the ionic cli has a more easy way to crete a shared module. You just hast to run the command
    ionic g module shared (or wharever name you want)
    and it will create the module with the necesary structure you need

  • @MurilloVieira
    @MurilloVieira 5 ปีที่แล้ว

    Man, you're just awesome. I've spent a lot of time trying to figure out how normal angular components should work for ionic 4 and you've just lit my way. Thanks a lot!!

  • @olumideayeni143
    @olumideayeni143 4 ปีที่แล้ว +1

    Josh!!!..... Thank you, you really saved my day with this... I am so glad that i found this at the right now.

  • @shaunbrassell68
    @shaunbrassell68 4 ปีที่แล้ว

    Great video - taking one through the failure process was key to me learning, excellent job!

  • @DavidHodges47
    @DavidHodges47 5 ปีที่แล้ว

    This really solved my problem. Most of the other results from Google searching were wrong about this, possibly due to changes in versions of ionic or angular.
    I do wish that you could make the source code for this one example available on github or something similar.
    Also, when you use "ionic generate module", it generates a "spec" file, which throws errors unless you delete it.

  • @doronsayar1587
    @doronsayar1587 ปีที่แล้ว

    Thanks man, you saved me from a mental breakdown!

  • @sapsapproductivity
    @sapsapproductivity 3 ปีที่แล้ว

    Thanks Joshua,
    Well explained.

  • @mohammadhadiemami2670
    @mohammadhadiemami2670 5 ปีที่แล้ว +1

    you saved 2 hours of my time!! THANKS

  • @muzz88
    @muzz88 5 ปีที่แล้ว

    Nice one, I was convinced I was never going to use shared components in ionic until this. Thanks

  • @rodrigomgsys
    @rodrigomgsys 5 ปีที่แล้ว

    Great tutorial, It has worked perfectly for me. I was facing this error when tried to load a custom component in a PageModule. Thank you very much for sharing. :-)

  • @sathvikakopalli2574
    @sathvikakopalli2574 2 ปีที่แล้ว

    That was really a great explanation you have helped me a lot bro 🙌🙌
    Hope you continue doing lectures like these 🥺

  • @AcquahEmmanuelBaiden
    @AcquahEmmanuelBaiden 2 ปีที่แล้ว

    Thanks Joshua. This was very useful

  • @crassProgrammer
    @crassProgrammer 3 ปีที่แล้ว

    This was what exactly I wanted. Thankyou very much!!

  • @rudikatzer1606
    @rudikatzer1606 2 ปีที่แล้ว

    Amazing. Works for me in 2022

  • @allan9537
    @allan9537 4 ปีที่แล้ว +1

    Thank you so much! Saved my day!!

  •  5 ปีที่แล้ว +1

    Great tutorial!
    If you're thinking about a new one, can you please make a tutorial about importing JavaScript or npm packages to Ionic 4? The other day I needed to import Bson to my Ionic 4 project but I had a bunch of errors and I quit.

  • @izzatullokanoatov370
    @izzatullokanoatov370 5 ปีที่แล้ว

    I will take off my hat in front of your tutorials. Best of the best.

  • @mekbeb
    @mekbeb 5 ปีที่แล้ว

    Thanks Josh, nice quick and easy explanation. God bless!

  • @lesetjalese7462
    @lesetjalese7462 2 ปีที่แล้ว

    Thanks this really saved my day.

  • @zhoobinjalili5946
    @zhoobinjalili5946 3 ปีที่แล้ว

    Great, helped me a lot! Thanks Joshua!

  • @grab0wski
    @grab0wski 5 ปีที่แล้ว +1

    Thank you Joshua Morony, you saved my day, I spended amount of time this morning to resolv this issue =))

  • @kyatar
    @kyatar 4 ปีที่แล้ว

    you just made my day, thanks for the awesome explanation

  • @Garciia
    @Garciia 2 ปีที่แล้ว

    Hey still useful, I've been trying to get into it and this clear my head around the subject, ty

  • @sebasA
    @sebasA 3 ปีที่แล้ว

    Hi thanks for the video, Im using the Ionic side-bar template and in a page I desided to add a component just like you with a module, the problem is the sidebar cant be slide if mi finger pass trough the component. For fix it I just reduced the component area to slide the sidebar but the sidebar looks lagy (just happen in the page where I added the component).

  • @sarath9077
    @sarath9077 5 ปีที่แล้ว +1

    Thank you so much Joshua.
    I have one question though. System throws error when I use ion elements like ion-item etc inside my custom component. How do we solve that issue?

    • @sarath9077
      @sarath9077 5 ปีที่แล้ว +1

      Update: It got fixed by adding CUSTOM_ELEMENTS_SCHEMA in the schema of component.module.ts.
      schemas: [ CUSTOM_ELEMENTS_SCHEMA ],

    • @karlzone2
      @karlzone2 4 ปีที่แล้ว

      Sorry, I know this is five months late, but do you know why this happens? I used loads of ion elements, but didn't get this error, though I saw someone on a forum suggesting your solution. What does CUSTOM_ELEMENTS_SCHEMA do? It's clearly important (or at least it used to be?)?!

  • @yorlandIII
    @yorlandIII 2 ปีที่แล้ว

    Amazing!! thank you for the detailed explanation!!

  • @ThukuWakogi
    @ThukuWakogi 5 ปีที่แล้ว

    You saved a life sir

  • @VinayKumar-bl2ob
    @VinayKumar-bl2ob ปีที่แล้ว

    Thanks a lot, you are great at explaining👍👍👍

  • @devinvail67
    @devinvail67 5 ปีที่แล้ว +2

    As always, love your tutorials. In this one you added background music, not sure why. I found it distracting. Following your voice and the code is enough data to handle for my brain :-)

  • @argieabedejos760
    @argieabedejos760 4 ปีที่แล้ว

    Thanks man. This saves my day.

  • @Sandeep-vr8ri
    @Sandeep-vr8ri 4 ปีที่แล้ว

    nice and simple , thanks bro.

  • @jacobsultd
    @jacobsultd 3 ปีที่แล้ว

    Thank you Joshua. Saved me..

  • @ciaranmooney1912
    @ciaranmooney1912 3 ปีที่แล้ว

    Very useful video, thanks

  • @chularansifernando5
    @chularansifernando5 5 ปีที่แล้ว

    Thank you, I also need to know how to use one page on multiple pages in ionic 4? Could you please add another video for that.

  • @fcsalmeida
    @fcsalmeida 5 ปีที่แล้ว

    Thank you! You are the man! It saved me from a big problem !!

  • @psv6009
    @psv6009 4 ปีที่แล้ว

    Thanks too much your video, you solved ' 2 modules' for me.

  • @ginil
    @ginil 4 ปีที่แล้ว

    in the ionic 4 conference app, there aren't any components, just pages. Is it possible to include a page in another page, just like a component?

  • @bankoleemmanuel1088
    @bankoleemmanuel1088 5 ปีที่แล้ว

    Thanks Joshua

  • @aliciajanssen6548
    @aliciajanssen6548 5 ปีที่แล้ว

    Thank you! The instructions are fantastic!

  • @Arudion
    @Arudion 5 ปีที่แล้ว +7

    Additional:
    - If you want to use nested components, you have to add them to the entryComponents of the ComponentsModule
    - If you want to use Ionic Components, you have to add IonicModule to the imports of the ComponentsModule

    • @babyamg
      @babyamg 5 ปีที่แล้ว +2

      Example: const tmpModule = NgModule({
      declarations: [tmpCmp],
      imports:[IonicModule],
      entryComponents: [tmpCmp],
      })(class {});

    • @MarioShtika
      @MarioShtika 5 ปีที่แล้ว +2

      ​and also if you want to use things like `*ngIf` you should import `BrowserModule`, but because this is already imported on app.module.ts you should import `CommonModule` instead
      `imports: [IonicModule, CommonModule],`

    • @karlzone2
      @karlzone2 4 ปีที่แล้ว +1

      I should have read your comment @Mario, god damn. But yeah, if you wanna use NgFor, NgIf, then do :import { CommonModule } from '@angular/common';

  • @daveycrockettjr
    @daveycrockettjr 5 ปีที่แล้ว

    When using a custom component on multiple pages I notice that the component is created again (or at least ngInit() fires again). Is there a way to make a component that is at the root level and is not re-created if used on two pages?

  • @jesusdcg7583
    @jesusdcg7583 4 ปีที่แล้ว

    Well explained, thank you

  • @videodr.9402
    @videodr.9402 4 ปีที่แล้ว

    Thanks, Joshua Morony, you saved my day :)

  • @RahulYadav-hs2un
    @RahulYadav-hs2un 4 ปีที่แล้ว +1

    Nice Video

  • @jeffcordova
    @jeffcordova 5 ปีที่แล้ว +1

    Josh! Thank you for this! Thank you for saving me again. :)

  • @javierandresfernandez6373
    @javierandresfernandez6373 3 ปีที่แล้ว

    Sorry if this is a trivial question but, what if I have defined a method inside a custom component, and I want to call it from an ion-button in a particular page. Supposing I had already done what it is told in this tutorial, how can I call that method?

    • @JoshuaMorony
      @JoshuaMorony  3 ปีที่แล้ว

      You would just need a reference to the component you are calling the method on (e.g. grabbing it through @ViewChild), then with the reference you just call it like this.myComponent.myMethod();

  • @youngwise14
    @youngwise14 4 ปีที่แล้ว

    Thanks man! This was right on time.

  • @magicalkunal
    @magicalkunal 3 ปีที่แล้ว

    Thanks. it helped me a lot.

  • @joeporsche1767
    @joeporsche1767 4 ปีที่แล้ว

    You just save my day. Thank!!!

  • @taha5049
    @taha5049 2 ปีที่แล้ว

    Thanks Good Lad you Saved my day!!

  • @sukdipkar8876
    @sukdipkar8876 3 ปีที่แล้ว

    how can use the component.css file in the page?

  • @vp3275
    @vp3275 5 ปีที่แล้ว

    Great quality, you deserve mor views :) Thanks !

  • @WajahathKhan04
    @WajahathKhan04 5 ปีที่แล้ว

    Thanks Man, 1000 Likes :) You just give me the result of my struggling 5 hrs

  •  3 ปีที่แล้ว

    Thanks for the video!

  • @walaazahran29
    @walaazahran29 ปีที่แล้ว

    thanks you helped me so much !

  • @Karthik1516
    @Karthik1516 5 ปีที่แล้ว

    I had the exact same error. Thank you.

  • @rStudius
    @rStudius 3 ปีที่แล้ว

    Thanks a lot! Helped me so muuuch

  • @JosephAli93
    @JosephAli93 5 ปีที่แล้ว +1

    I think i follow tutorial step by step, but got ERROR Error: "Uncaught (in promise): Error: Unexpected module 'TestComponentPageModule' declared by the module 'TestComponentPageModule'. Please add a @Pipe/@Directive/@Component annotation.

  • @philipvandrunen3728
    @philipvandrunen3728 5 ปีที่แล้ว

    Thank you, thank you, thank you. I still don't completely understand, but at least my code is working again!

  • @yccodei
    @yccodei 3 ปีที่แล้ว

    Thanks a lot for your help

  • @nileshupadhyay7248
    @nileshupadhyay7248 4 ปีที่แล้ว

    Hey Josh thanks a lot buddy, you saved my time.... Yes I really enjoyed the tutorial.. :)

  • @emartosgomez
    @emartosgomez 5 ปีที่แล้ว

    Thank you so much! Really useful!

  • @erna3477
    @erna3477 5 ปีที่แล้ว

    Saved my night... Thank you!

  • @MounikaUmmidi
    @MounikaUmmidi ปีที่แล้ว

    Thank you !

  • @emyprinso
    @emyprinso 4 ปีที่แล้ว

    ./src/app/home/home.module.ts 19:31-39
    "export 'HomePage' was not found in './home.page'
    that is the error I am getting, if I can get your source code and use it as a boilerplate for my app I will appreciate it

  • @tpamarasekera
    @tpamarasekera 5 ปีที่แล้ว

    Great tutorial! !!!!!

  • @zeerodev
    @zeerodev 5 ปีที่แล้ว

    Thanks alot for this solution

  • @jluis859
    @jluis859 5 ปีที่แล้ว

    saved my life

  • @carlosgaleanohn
    @carlosgaleanohn 5 ปีที่แล้ว

    Is more easy than Ionic 3... TY for the explaining it!

  • @muhammadhussainn4389
    @muhammadhussainn4389 5 ปีที่แล้ว

    Thank you for this video!

  • @mojinzhang2250
    @mojinzhang2250 5 ปีที่แล้ว

    super helpful thanks!

  • @jamesdavidwyers9110
    @jamesdavidwyers9110 2 ปีที่แล้ว

    1:01 Glad I'm not the only one with this problem....😅

  • @27brenner
    @27brenner 3 ปีที่แล้ว

    THANK YOU

  • @vidalroland
    @vidalroland 5 ปีที่แล้ว +1

    Great !
    I have a problem with custom components. When I create a header component, it goes over the pages (no margin at the top of the page).
    You can see it there :
    ipassed.it
    Does someone have any idea on how to solve it ?

  • @cdevidal
    @cdevidal 4 ปีที่แล้ว

    Appreciate it! I should have checked your video first :-)

  • @andriyzhuk8830
    @andriyzhuk8830 4 ปีที่แล้ว

    Thanks!

  • @manarmohammad8232
    @manarmohammad8232 ปีที่แล้ว

    thank you

  • @luisdonis2147
    @luisdonis2147 4 ปีที่แล้ว

    Thank you sooooo much!!!

  • @elmergarcia.a5536
    @elmergarcia.a5536 4 ปีที่แล้ว

    thank you!!

  • @wealth_developer_researcher
    @wealth_developer_researcher 3 ปีที่แล้ว

    Thanks!!! It helped me :)

  • @Hicham_SaAh
    @Hicham_SaAh 5 ปีที่แล้ว

    thank you , i have one question please , if i have 2 folders one called example same what you made and the second called example_2 but i want to show example_2 in the home page and example into detail page . is it possible ? and how it will be !
    thanks in advance ...

    • @JoshuaMorony
      @JoshuaMorony  5 ปีที่แล้ว +3

      So you want two separate components, one goes on the home page one goes on the detail page? You could do a variety of things. If you are only using the components on one page each you could just add them as a declaration to that pages module and ignore creating a components module altogether. You could create a single shared component module (like in the video) that includes both of the components, and then include that shared components module in both of your page modules. Or, you could create a separate module for each of your two components (same as the video except instead of components.module.ts you would have example-one.module.ts and example-two.module.ts), and then import the appropriate module into the module for the page you want to use it on.

    • @Hicham_SaAh
      @Hicham_SaAh 5 ปีที่แล้ว

      @@JoshuaMorony thank you so much

  • @thellexacademy
    @thellexacademy 5 ปีที่แล้ว

    Nice One

  • @developpeuranonyme9428
    @developpeuranonyme9428 5 ปีที่แล้ว

    Thank you very much, that helped me a lot :)

  • @HOW-bt3et
    @HOW-bt3et 5 หลายเดือนก่อน

    thanks man

  • @DieDie-us4oo
    @DieDie-us4oo 5 ปีที่แล้ว

    Thank you man!!

  • @noursidaoui8278
    @noursidaoui8278 4 ปีที่แล้ว

    I tried importing IonicModule to my components.module in order to use Ionic elements but my page refreshes for a couple of minutes and throws a "Maximum call stack size exceeded" error.
    I tried adding CUSTOM_ELEMENTS_SCHEMA in the schema of component.module.ts and the same error happens
    Please help, I've been stuck on this for a day now :s

    • @snaidher5
      @snaidher5 4 ปีที่แล้ว

      I have the same error, and in my component I put this
      @NgModule(
      {
      imports:[IonicModule],
      declarations: [ProductoComponent],
      exports: [ProductoComponent]
      }
      )

  • @calina9939
    @calina9939 4 ปีที่แล้ว

    pretty Josh thks x)

  • @MOHAMMEDSOKAILY
    @MOHAMMEDSOKAILY 4 ปีที่แล้ว

    Thank you, you saved my day

  • @kinetik2018
    @kinetik2018 5 ปีที่แล้ว

    muchas gracias !!!

  • @mehdi907
    @mehdi907 5 ปีที่แล้ว

    when I created the component it wasn't declared automatclly on module.ts why?

    • @Dxpress_
      @Dxpress_ 5 ปีที่แล้ว

      Yep, same here. Been spending hours wondering why generated components don't just work.

  • @israelnunesoriente7722
    @israelnunesoriente7722 3 ปีที่แล้ว

    VOCE É Incrivellll

  • @comformarkwebsite8833
    @comformarkwebsite8833 5 ปีที่แล้ว

    Thanks Joshua, another excellent explanation! Can you perhaps create an additional video that explains how to use a component within a component? Or, how to add a component to a page that was created as a component - ie. Using a component as a page, so the router points to "component: MyPageComponent" - now MyPageComponent doesn't have a module, so how do I add custom components to it? (This process works in Angular 7, but "does my head in" using Ionic 4 ! )

  • @TobiasRohde
    @TobiasRohde 5 ปีที่แล้ว

    What if I want to use Ionic elements in my custom component? I try to create a custom component for the application header and want use ion-header, ion-toolbar and so on. As long as I use normal HTML elements everything works. Using Ionic elements they are unknown.
    ERROR Error: Uncaught (in promise): Error: Template parse errors:
    'ion-menu-button' is not a known element:
    1. If 'ion-menu-button' is an Angular component, then verify that it is part of this module.
    2. If 'ion-menu-button' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

    • @TobiasRohde
      @TobiasRohde 5 ปีที่แล้ว +1

      Found the solution by myself: stackoverflow.com/questions/43425090/ionic-3-cant-use-ion-components-inside-my-custom-components