I had succeeded embedding an Angular application within a .NET MAUI app by setting the WebView source to the index.html
of the Angular build output.
Steps I followed:
In angular.json
, set the outputPath of the Angular build to wwwroot/angular
directory within the MAUI project.
"outputPath": "../Maui/wwwroot/angular"
In the MAUI project, set the WebView source in MainPage.xaml
:
<WebView x:Name="webView" Source="wwwroot/angular/browser/index.html" />
This approach allowed me to render Angular components inside my MAUI WebView on both mobile and desktop apps.
Limitation: The limitation of this approach is that accessing platform-specific APIs (such as sensors, file system, etc.) from the Angular app is tricky.
I tried using JSInterop
, but I couldn't get it to work as expected.
From the DevConsole, I was able to invoke the method successfully, but for some reasons, it did not work when I added the same script in the Angular scripts.