'angular 11 custom elements in new angular app
I am able to build the angular element and using a raw HTML page use the created src perfectly fine:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./custom-button-element.js"></script>
<title>Document</title>
</head>
<body>
<app-button name="WORKS!!!"></app-button>
</body>
</html>
However when I try this example in a angular application I get the following err:
Request URL: http://localhost:4200/custom-button-element.js
Request Method: GET
Status Code: 404 Not Found
I have in the ''app.module.ts'' created a schema:
schemas: [
CUSTOM_ELEMENTS_SCHEMA
]
and my ''app.component.html'' looks like the following:
<h1>Container...</h1>
<app-button name="Test"></app-button>
my angular app ''index.html'' looks like this:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Container</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script src="./custom-button-element.js"></script>
</head>
<body>
<app-root></app-root>
</body>
</html>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
