Extended custom elements not working in Angular 2+ The Next CEO of Stack OverflowExtending native HTML element in Angular 6How do JavaScript closures work?How do I detect a click outside an element?How do I check if an element is hidden in jQuery?Event binding on dynamically created elements?How does JavaScript .prototype work?How can I select an element with multiple classes in jQuery?How to move an element into another element?How do I remove a particular element from an array in JavaScript?jQuery scroll to elementHow does data binding work in AngularJS?
Which one is the true statement?
What would be the main consequences for a country leaving the WTO?
Is there such a thing as a proper verb, like a proper noun?
Physiological effects of huge anime eyes
Is it convenient to ask the journal's editor for two additional days to complete a review?
Getting Stale Gas Out of a Gas Tank w/out Dropping the Tank
Computationally populating tables with probability data
Is there a way to save my career from absolute disaster?
How to avoid supervisors with prejudiced views?
Do scriptures give a method to recognize a truly self-realized person/jivanmukta?
Won the lottery - how do I keep the money?
Why did early computer designers eschew integers?
What CSS properties can the br tag have?
"Eavesdropping" vs "Listen in on"
Why don't programming languages automatically manage the synchronous/asynchronous problem?
How did Beeri the Hittite come up with naming his daughter Yehudit?
From jafe to El-Guest
How do I fit a non linear curve?
What are the unusually-enlarged wing sections on this P-38 Lightning?
What does "shotgun unity" refer to here in this sentence?
Are the names of these months realistic?
Is dried pee considered dirt?
Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?
Why do we say 'Un seul M' and not 'Une seule M' even though M is a "consonne"
Extended custom elements not working in Angular 2+
The Next CEO of Stack OverflowExtending native HTML element in Angular 6How do JavaScript closures work?How do I detect a click outside an element?How do I check if an element is hidden in jQuery?Event binding on dynamically created elements?How does JavaScript .prototype work?How can I select an element with multiple classes in jQuery?How to move an element into another element?How do I remove a particular element from an array in JavaScript?jQuery scroll to elementHow does data binding work in AngularJS?
I can't get Angular (2+, not AngularJS) to play nice with my extended custom element, which is defined like so:
class FancyButton extends HTMLButtonElement
connectedCallback()
this.innerText = `I'm a fancy-button!`;
this.style.backgroundColor = 'tomato';
customElements.define("fancy-button", FancyButton,
extends: "button"
);
And used like so:
<button is="fancy-button">Fancy button here</button>
The definition is fully compliant to web standards according to this Google Developer resource:
https://developers.google.com/web/fundamentals/web-components/customelements#extend
It's working fine in a vanilla web setup and in React, but Angular ignores it and shows a standard button, apparently ignoring the is="fancy-button" attribute.
Here is a stackblitz showing this in action.
One fancy-button is outside the Angular scope (index.html) and is working fine.
The other button is inside the Angular scope (app.component.html) and is NOT working.
Why oh why?
javascript angular
add a comment |
I can't get Angular (2+, not AngularJS) to play nice with my extended custom element, which is defined like so:
class FancyButton extends HTMLButtonElement
connectedCallback()
this.innerText = `I'm a fancy-button!`;
this.style.backgroundColor = 'tomato';
customElements.define("fancy-button", FancyButton,
extends: "button"
);
And used like so:
<button is="fancy-button">Fancy button here</button>
The definition is fully compliant to web standards according to this Google Developer resource:
https://developers.google.com/web/fundamentals/web-components/customelements#extend
It's working fine in a vanilla web setup and in React, but Angular ignores it and shows a standard button, apparently ignoring the is="fancy-button" attribute.
Here is a stackblitz showing this in action.
One fancy-button is outside the Angular scope (index.html) and is working fine.
The other button is inside the Angular scope (app.component.html) and is NOT working.
Why oh why?
javascript angular
I wouldn't even go that way... we have directives to use just for cases like this :) stackblitz.com/edit/angular-lqz3xt?file=src/app/…
– AJT_82
Mar 21 at 19:29
I see. I'm doing this to be framework agnostic and I think the "is="fancy-button" approach is very nice for that. Works perfectly in React without any React-specific code.
– Kim Andersen
Mar 21 at 19:32
I'm not using the <script> tag in a template. It's in the index.html file. However, I get your point and thanks for your reply. This question is about the same issue if you're interested: stackoverflow.com/questions/53604958/…
– Kim Andersen
Mar 21 at 19:48
add a comment |
I can't get Angular (2+, not AngularJS) to play nice with my extended custom element, which is defined like so:
class FancyButton extends HTMLButtonElement
connectedCallback()
this.innerText = `I'm a fancy-button!`;
this.style.backgroundColor = 'tomato';
customElements.define("fancy-button", FancyButton,
extends: "button"
);
And used like so:
<button is="fancy-button">Fancy button here</button>
The definition is fully compliant to web standards according to this Google Developer resource:
https://developers.google.com/web/fundamentals/web-components/customelements#extend
It's working fine in a vanilla web setup and in React, but Angular ignores it and shows a standard button, apparently ignoring the is="fancy-button" attribute.
Here is a stackblitz showing this in action.
One fancy-button is outside the Angular scope (index.html) and is working fine.
The other button is inside the Angular scope (app.component.html) and is NOT working.
Why oh why?
javascript angular
I can't get Angular (2+, not AngularJS) to play nice with my extended custom element, which is defined like so:
class FancyButton extends HTMLButtonElement
connectedCallback()
this.innerText = `I'm a fancy-button!`;
this.style.backgroundColor = 'tomato';
customElements.define("fancy-button", FancyButton,
extends: "button"
);
And used like so:
<button is="fancy-button">Fancy button here</button>
The definition is fully compliant to web standards according to this Google Developer resource:
https://developers.google.com/web/fundamentals/web-components/customelements#extend
It's working fine in a vanilla web setup and in React, but Angular ignores it and shows a standard button, apparently ignoring the is="fancy-button" attribute.
Here is a stackblitz showing this in action.
One fancy-button is outside the Angular scope (index.html) and is working fine.
The other button is inside the Angular scope (app.component.html) and is NOT working.
Why oh why?
javascript angular
javascript angular
asked Mar 21 at 19:09
Kim AndersenKim Andersen
2215
2215
I wouldn't even go that way... we have directives to use just for cases like this :) stackblitz.com/edit/angular-lqz3xt?file=src/app/…
– AJT_82
Mar 21 at 19:29
I see. I'm doing this to be framework agnostic and I think the "is="fancy-button" approach is very nice for that. Works perfectly in React without any React-specific code.
– Kim Andersen
Mar 21 at 19:32
I'm not using the <script> tag in a template. It's in the index.html file. However, I get your point and thanks for your reply. This question is about the same issue if you're interested: stackoverflow.com/questions/53604958/…
– Kim Andersen
Mar 21 at 19:48
add a comment |
I wouldn't even go that way... we have directives to use just for cases like this :) stackblitz.com/edit/angular-lqz3xt?file=src/app/…
– AJT_82
Mar 21 at 19:29
I see. I'm doing this to be framework agnostic and I think the "is="fancy-button" approach is very nice for that. Works perfectly in React without any React-specific code.
– Kim Andersen
Mar 21 at 19:32
I'm not using the <script> tag in a template. It's in the index.html file. However, I get your point and thanks for your reply. This question is about the same issue if you're interested: stackoverflow.com/questions/53604958/…
– Kim Andersen
Mar 21 at 19:48
I wouldn't even go that way... we have directives to use just for cases like this :) stackblitz.com/edit/angular-lqz3xt?file=src/app/…
– AJT_82
Mar 21 at 19:29
I wouldn't even go that way... we have directives to use just for cases like this :) stackblitz.com/edit/angular-lqz3xt?file=src/app/…
– AJT_82
Mar 21 at 19:29
I see. I'm doing this to be framework agnostic and I think the "is="fancy-button" approach is very nice for that. Works perfectly in React without any React-specific code.
– Kim Andersen
Mar 21 at 19:32
I see. I'm doing this to be framework agnostic and I think the "is="fancy-button" approach is very nice for that. Works perfectly in React without any React-specific code.
– Kim Andersen
Mar 21 at 19:32
I'm not using the <script> tag in a template. It's in the index.html file. However, I get your point and thanks for your reply. This question is about the same issue if you're interested: stackoverflow.com/questions/53604958/…
– Kim Andersen
Mar 21 at 19:48
I'm not using the <script> tag in a template. It's in the index.html file. However, I get your point and thanks for your reply. This question is about the same issue if you're interested: stackoverflow.com/questions/53604958/…
– Kim Andersen
Mar 21 at 19:48
add a comment |
0
active
oldest
votes
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55287677%2fextended-custom-elements-not-working-in-angular-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55287677%2fextended-custom-elements-not-working-in-angular-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I wouldn't even go that way... we have directives to use just for cases like this :) stackblitz.com/edit/angular-lqz3xt?file=src/app/…
– AJT_82
Mar 21 at 19:29
I see. I'm doing this to be framework agnostic and I think the "is="fancy-button" approach is very nice for that. Works perfectly in React without any React-specific code.
– Kim Andersen
Mar 21 at 19:32
I'm not using the <script> tag in a template. It's in the index.html file. However, I get your point and thanks for your reply. This question is about the same issue if you're interested: stackoverflow.com/questions/53604958/…
– Kim Andersen
Mar 21 at 19:48