handing js object to angularjs

I am attempting to create my own dashboard to display data provided by my Home Assistant server. Given the script below, which I have working fine, how do I hand off the output from subscribeEntities(connection, entities);to angularjs rather than the renderEntities function? The goal is to be able to use angularjs expressions to populate my dashboard with data. According to the documentation here, I think subscribeEntities(connection, entities)provides a js object but i’m not 100% sure of that.

Thanks for helping out. Any help or hints are appreciated!

Baobab

<html>
  <body>
    <table>
      <tbody></tbody>
    </table>
    <script type="module">
      import {
        getAuth,
        getUser,
        callService,
        createConnection,
        subscribeEntities,
        ERR_HASS_HOST_REQUIRED
      } from "./dist/index.js";

      (async () => {
        let auth;
        try {
          auth = await getAuth();
        } catch (err) {
          if (err === ERR_HASS_HOST_REQUIRED) {
            const hassUrl = prompt(
              "What host to connect to?",
              "http://ip-of-ha:8123"
            );
            if (!hassUrl) return;
            auth = await getAuth({ hassUrl });
          } else {
            alert(`Unknown error: ${err}`);
            return;
          }
        }
        const connection = await createConnection({ auth });
        subscribeEntities(connection, entities =>
          renderEntities(connection, entities)
        );
        // Clear url if we have been able to establish a connection
        if (location.search.includes("auth_callback=1")) {
          history.replaceState(null, "", location.pathname);
        }

        // To play from the console
        window.auth = auth;
        window.connection = connection;
        getUser(connection).then(user => {
          console.log("Logged in as", user);
          window.user = user;
        });
      })();

      function renderEntities(connection, entities) {
        const root = document.querySelector("tbody");
        while (root.lastChild) root.removeChild(root.lastChild);

        Object.keys(entities)
          .sort()
          .forEach(entId => {
            const tr = document.createElement("tr");

            const tdName = document.createElement("td");
            tdName.innerHTML = entId;
            tr.appendChild(tdName);

            const tdState = document.createElement("td");
            const text = document.createTextNode(entities[entId].state);
            tdState.appendChild(text);

            if (
              ["switch", "light", "input_boolean"].includes(
                entId.split(".", 1)[0]
              )
            ) {
              const button = document.createElement("button");
              button.innerHTML = "toggle";
              button.onclick = () =>
                callService(connection, "homeassistant", "toggle", {
                  entity_id: entId
                });
              tdState.appendChild(button);
            }
            tr.appendChild(tdState);

            root.appendChild(tr);
          });
      }
    </script>
  </body>
</html>

Source: Angular Questions