How to create my own html tag

Hello,

i want to create my own html tag to transform :

<div class="class">
   <div class="subClass">
   </div>
</div>

to :

<class>
    <subClass>
    </subClass>
</class>

What i find is to do something like this :

class {
    //css
}

document.createElement('class');

But i don’t know how to add a custom script, or where i can add this line.

thanks !

hello,

maybe what are you looking for are custom components.

Here for a simple one. https://audacitus.com/site/2017/01/04/custom-feed-component-ionic-2-part-1/

Best regards, anna-liebt

Hello,

i just want to ceate html tag to use css on them without write <div class="class"> </div> but <class> </class> to write code speedly.

Your example looks like “include file”

Thanks

Did you try this?

CSS

tag{ 
. . .
}

HTML

<tag> . . . </tag>

Yep but i get an error :

Uncaught Error: Template parse errors:
'hs' is not a known element:
1. If 'hs' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
</ion-header>

[ERROR ->]<hs> test </hs>

This is the solution for you. Try this.

1 Like

Juste like that :

  schemas: [
    NO_ERRORS_SCHEMA
  ]

:o i’m so stupid …

thanks :wink:

:grinning::+1:

Sometimes we ignore the error messages and tricks for solutions

1 Like