Giter Site home page Giter Site logo

Comments (3)

joeldenning avatar joeldenning commented on September 27, 2024

The domElementGetter returning null because the document.body is not ready yet.

Your code must be pretty different than the coexisting-angular-microfrontends code, since we call singleSpa.start() inside of document.body.

You should not need to worry about any of this. single-spa-angular creates a dom element container for you without you having to create it in the html file or your own custom domElementGetter.

To fix your code, just put your javascript into the <body> element of the HTML.

I'm closing this since this does not seem like an issue with coexisting-angular-microfrontends and I've given you a way to fix it.

from coexisting-angular-microfrontends.

baggelisp avatar baggelisp commented on September 27, 2024

The code is exacly the sameas the coexisting-angular-microfrontends code but in the navbar app i want to have a sidebar instead of navbar.So my code in the navbar html is like this:

<div class="container-fluid">
    <div class="row">
        <div class="col-3">
            <div style="text-align:center">
                <h1>
                    Sidebar
                </h1>
                <div class="list-group list-group-flush">
                    <a routerLink="/home" href="#">Home</a>
                    <a routerLink="/login" href="#">Log in</a>
                </div>
            </div>
        </div>
        <div class="col-9">
            <div id="main-section">
            </div>
        </div>
    </div>
</div>

And i want to place my home-page-app inside div with id "main-section"

So in the home-page app in the main.single-spa.ts i put the function:

function domElementGetter() {
  let el = document.getElementById('main-section');
  if (!el) {
    el = document.createElement('div');
    el.id = 'main-section';
    document.body.appendChild(el);
  }
  return el;
}

All working well and i have this result:

1

But when back button is pressed the document.getElementById('main-section') returns undefined and this happened:

2

That is the reason why i changed the code in the main.single-spa.ts in the home-page app to the code i posted to find the element first and after return the DOM element.
But as i saw in the console with the comments the main.single-spa.ts is running before the DOM is generated and that is why return undefined.

from coexisting-angular-microfrontends.

joeldenning avatar joeldenning commented on September 27, 2024

For back button related issues, see single-spa/single-spa-angular#94.

Your error makes no sense for it to be related to the back button. Please push your code to github and we can reopen this for me to look at. The setInterval stuff you have is incorrect and shouldn't be needed.

from coexisting-angular-microfrontends.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.