Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pattern Factory return [object Object] in my HTML

When I use my pattern factory for my slider, it returns me "[object Object]" instead of having HTML.
Class code

HTML develop tools

Do you have any idea what could happen?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thank you so much 🙂

>Solution :

Contructor cann’t return anything, but the object he creates and returns internally. To avoid this behavior use something like.

   class MediaFactory {
      getContent(data, layout) {
         // your code goes here
      }

   }

and usage will be

....innerHtml = new MediaFactory().getContent(article, 'slider')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading