0

I'm using ASP.Net MVC/Web API behind an Angular 2 app. Everything is done in Angular EXCEPT logging in, which is a traditional MVC view and controller.

When I load up the login page everything works fine but the console is flooded with errors with this at the root:

The selector "app" did not match any elements

What is a simple and effective way to just prevent the Angular app from bootstrapping unless I'm on a certain controller or view, or prevent it from bootstrapping in a certain URL, or to generally make the flood of console errors go away on the login screen?

Methodician
  • 2,396
  • 5
  • 30
  • 49
  • have you considered using a standalone login page? Not really clear where those errors are being generated or how your login system works – charlietfl Sep 27 '16 at 00:05
  • 1
    Just don't call `platform.bootstrap(...)` when you don't want to load the Angular2 app. You can also try http://stackoverflow.com/questions/37611549/how-to-pass-parameters-rendered-from-backend-to-angular2-bootstrap-method but I don't know if this prevents your error message. – Günter Zöchbauer Sep 27 '16 at 05:28

1 Answers1

0

I know it is too late to answer but in case you are still having problems with trying to ignore angular 5 in some asp.net mvc view, you can do the following: instead of loading the main.ts in _layout.cshtml, load it within the view that you want to access, and not globally.

cut this code:

<script>
      System.import('/app/main.js').catch(function(err){ console.error(err); });
</script>

from Layout.cshtml and paste it in index.cshtml, then angular will be loaded only at index.cshtml and still authentication and registration can work as standard ASP.NET MVC

aRi_D
  • 25
  • 4