I have successfully developed an Angular application, and now I am looking to integrate it with a content management system that generates static pages. In order to achieve this, I need to utilize content projection from the main index.html
file.
The desired structure would look like this:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AngularCMS</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root>Content injected from index.html</app-root>
</body>
</html>
Next, the app-root
component can implement content projection by including
<ng-content></ng-content>
in its template:
@Component({
selector: 'app-root',
template: '<p>External Content Projection:<ng-content></ng-content></p>',
styleUrls: ['./app.component.css']
})
export class AppComponent { }
However, when trying this out, the result does not match the expected output. The rendered text ends up being:
- External Content Projection:1111
This leads me to my question:
- Is it feasible to apply content projection from outside the Angular application, similar to the example shared above?
- If yes, then how can this be achieved? If no, what are the limitations?
Edit: Some may wonder about the purpose behind such integration. To provide some context: my Angular app includes customizable components for financial back-testing simulations. This involves fetching historical data, running tests, and displaying results graphically. I aim to showcase these simulations on platforms like WordPress, Dokuwiki, or even as static pages served by Apache. Here's a theoretical scenario:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example Buy & Hold Strategy</title>
<base href="./">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<p>This simulation demonstrates a pure <em>Buy & Hold</em> strategy, investing $100,001 in the S&P500 from January 1, 2000, to January 1, 2020:</p>
<app-root>
<simulation start="2000-01-01" end="2020-4-9" quotes="SPY">
<chart-report>
<chart-report-configuration show="SPY.CLOSE" showDataAs="LINE" showDataOn="LEFT" normalize="true"></chart-report-configuration>
<chart-report-configuration show="BAH.NAV" showDataAs="LINE" showDataOn="LEFT" normalize="true"></chart-report-configuration>
</chart-report>
<accounts>
<swiss-quote id="BAH" cash="100000">
<strategy>
<buy-and-hold assetName="SPY"></buy-and-hold>
</strategy>
</swiss-quote>
</accounts>
</simulation>
</app-root>
<p/>Additional information goes here.</p>
</body>
</html>