I am redesigning a website using angular as the frontend and keystoneJS as the backend. The site works as follows: editors load articles on the backend in a wysiwyg editor (tinymce) in keystone. Keystone saves it in a simple text/HTML format in a mongo database. The angular frontend then connects to the database and retrieves the article(s) it needs and displays it/them.
The article model in keystone has a number of attributes like author, extract, etc., but the key ones for this issue are 1) the full article text: article.content.extended (string) and 2) the footnotes: article.footnotes (array).
I would like to give the editors the ability to easily add footnote numbers in the article text by adding a simple angular component selector with the footnote number. This will avoid the need to have them input a lot HTML content manually. They would enter all the footnote information separately and the angular component will link the two together by index.
However, I have not been able to create this app-note component because when I tested to make sure that it would render in the browser if I added the angular app-note selector to the article text, it did not appear. So, my question is how to properly load data from a database that has angular selectors in it, so that angular can process them properly??
Currently, if I put in the selector like:
<app-note>1</app-note>
Then I only see "1" in the chrome inspector with no sign of the app-note selector.
Here is some of the relevant code I am using...
FullArticleComponent that get the article in full-article.component.ts:
import { PostsService } from './../../posts.service';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-full-article',
templateUrl: './full-article.component.html',
styleUrls: ['./full-article.component.css']
})
export class FullArticleComponent implements OnInit {
slug = 'initial slug';
article: any = 'initial article';
constructor(private postsService: PostsService, private route: ActivatedRoute) { }
ngOnInit() {
this.route.params.subscribe(params => {
this.slug = params['slug'];
this.article = this.postsService.getArticle(this.slug);
});
this.postsService.articleChanged.subscribe(
() => {
this.article = this.postsService.currentArticle;
}
);
}
}
Full article loaded by using innerHTML attribute in full-article.component.html:
<div class="post-content" [innerHTML]="article.content.extended"></div>