What is the strategy for app load page from database?

I’m trying to make an application that store HTML in SQLite database.
I’m using ionic 3 to do make this app and i’m new to Angular 4, I’m more familar with angularjs.
Until now, I known how to get HTML from SQLite, but I still don’t how can I pass it into an ionic 3 Page dynamically.
I want to do that because i want to implement the searching function for my HTML content.
Please help me.

Fee free to ignore my opinion, but I think this is a fatally flawed design. Angular wants templates to be available at build time, and for good reason.

1 Like

While I agree that making templates available at build time is the best for most situations, there are edge cases where it is not practical. For instance, imagine building a Bible app, will you create templates for each book and chapters? How would you implement search? What about bookmarking verses?

I think the OP might have a similar app in mind.

1 Like

As a counterpoint, how would you bookmark verses if everything is stored as HTML?

Instead, you can simply dynamically build the content of the template, without dynamically creating the template itself.

You could define a model that (roughly) looks like:

public book = {
    name: "Matthew",
    chapters: [
            name: "Chapter 1",
            verses: [
                    name: "Verse 1",
                    text: "This is the genealogy..."

Then create a view that (again roughly) looks like:

    <ion-list *ngFor="let verse of chapter">

The OP question specifically mentioned SQLite. Also, at the end of his question, he said “search HTML content”. My submission, assumed, he wants to load HTML content from storage and render it in a template and while I understood @rapropos reply as implying conversion of all content into templates. BTW, he will end up with something similar to your MV.

No. It’s perfectly reasonable to have domain-specific data representations such as @SigmundFroyd’s above. I outlined a similar data model for a bible app here previously. What I’m saying is not reasonable is to have said data model be raw HTML.

Thanks for your help, but my HTML contains angular syntax ( {{}} ) or angular components (</>), not only simple text, so I really need to dynamic create pages with template loaded from SQL.

I don’t mean to be rude, but this has come up over and over again. The Angular team, for what are IMHO very solid reasons, does not want to facilitate this. So, as I see it, you have two viable choices:

  • rethink your design
  • use another framework