I am new to loopback. Started with Loopback 4. I am trying to create a simple 'Hello world' application using Loopback4 and Angular8.
In my application.ts, I am pointing my static directive path to my angular application src folder.
// Set up default home page
this.static('/', path.join(__dirname, '../angular-app/src'));
So I can see normal HTML content from index.html file from angular-app/src/index.html file,
but it doesn't bind anything inside <app-root> </app-root>
I see in Loopback v3, middleware.json was used to host client application like this:
"files": {
"loopback#static": {
"params": "$!../client"
}
}
What I'm doing wrong here?
Thanks in advance.
I've managed to get it work in Loopback 4 with Angular 9. After an angular app
ng build
the contents of thedist/\<app-name\>
folder should be placed inside the loopbackpublic
folder.Then, in order for the angular router to work properly, all the HTML errors ( Specifically 404 Not found errors) should be redirected to the angular
index.html
.To do that we must bind
RestBindings.SequenceActions.REJECT
to a custom provider. Inapplication.ts
just include the new bindingThe
AngularRejectProvider
could be taken from the default reject provider in@loopback/rest/src/providers/reject.provider.ts
:The new part is the following which basically redirects all HTML errors to angular: