How to create my own html tag


#1

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 !


#2

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


#3

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


#4

Did you try this?

CSS

tag{ 
. . .
}

HTML

<tag> . . . </tag>


#5

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>

#6

This is the solution for you. Try this.


#7

Juste like that :

  schemas: [
    NO_ERRORS_SCHEMA
  ]

:o i’m so stupid …

thanks :wink:


#8

:grinning::+1:

Sometimes we ignore the error messages and tricks for solutions