question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Alasql into HTML not updating Angular-based page

See original GitHub issue

Working in Angular flavour Ionic (5.4.16)

Running the INTO HTML(cssSelector,options) command has no visible result and throws no error.

I’ve confirmed that the code is continuing to run after this line.

I feel like just dumping the contents of the html and ts files in here would be unhelpful but here’s a direct copy-paste of relevant lines.

HTML file <div id="res"></div>

**ts file **

res = alasql(queryToRun)
    console.log(res)
  
  if (res.length < 1){
      // Looks like the user didn't get any results back
      myError = "Looks like your query didn't return any results \n\n"
  
      if (queryToRun.toLowerCase().includes("where")){
          myError = myError+"Double check your 'where' statement to make sure the columns are right. \nAnd if you're searching for text you're putting that text in 'quotes' "
      }
  
      throw myError
  }

  console.log("Writing to html")
  
  res2 = alasql(`SELECT * INTO HTML("#res", { headers :true }) FROM ?`, [res])

  console.log(res2)

I’m not terribly experienced with Angular but have seen that it rejects attempts to update element contents directly. For example, in the same ts file I have to write the below to clear the contents from the div I want alasql to put this table into. If I don’t first

var output = document.querySelector('#res') as HTMLInputElement | null;
output.innerText = ''

I think alasql is updating html elements using el.innerHTML+=s which could be the problem.

A quick(er) solution than adding a specific workaround for this could be to give the option of returning html rather than json (sorry if I’ve missed that as an existing feature already).

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Robin-Lordcommented, Oct 31, 2022

Understood! Good to confirm and thanks for the pointer! Constructing the output myself was my next port-of-call but given how much thought you’ve put in to a bunch of this stuff it seemed silly not to try to use the logic you’ve already laid out.

I’ll probably make something Angular-native. Anywhere helpful to share it if I do?

0reactions
mathiasrwcommented, Oct 31, 2022

Share it here - then we get it into the wiki if it seems to be of general interest

Read more comments on GitHub >

github_iconTop Results From Across the Web

AlaSql error while exporting XLS from HTML with style formatting
During export XLS directly from HTML it works fine but I am not able to add some cell formatting in this process. I...
Read more >
Is alaSql work in Angular2? · Issue #738 - GitHub
Hi, I want to use alasql in my angular2 project, ... Let me know if anything is not working - then we look...
Read more >
alasql - npm
Start using alasql in your project by running `npm i alasql`. There are 107 other projects in the npm registry using alasql.
Read more >
RouterLinkActive - Angular
Tracks whether the linked route of an element is currently active, and allows you to specify one or more CSS classes to add...
Read more >
https://raw.githubusercontent.com/wiki/agershun/al...
_AlaSQL is an open source project used on more than two million page ... .com/agershun/alasql/develop/test/coverage/lcov-report/dist/alasql.fs.js.html) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found