0

I have an ASP.NET MVC 4.x application that I'm rewriting to make use of Angular2. Due to compatibility and time constraints it isn't possible to make it a single page application and therefore I need to use the routing of ASP.NET. Due to the fact that parts of the page will still be generated serversided by ASP.NET.

Basically what I want to do is sprinkle angular2 components in a static website(as far as Angular is concerned). An example:

<html>
    <body>
        <my-appmenu>Loading menu...</my-appmenu>
        some static text
        <my-appselectproduct>Loading the select product</my-appselectproduct> 
    </body>
 </html>

Would be one page, but another would look like this:

<html>
    <body>
        <my-appmenu>Loading menu...</my-appmenu>
        some other static text
        <my-appselectuser>Loading the select product</my-appselectuser> 
    </body>
</html>

Angular2 will crash doing this because it can't find the my-appselectuser selector in the first page and the my-appselectuser selector in the second page.

I found this earlier question which the answer seems to make it work, but it will still show a lot of errors like: EXCEPTION: Error in :0:0 caused by: The selector "my-appselectuser" did not match any elements

Does anyone know how to fix these errors? I would really like to do this withouth having to create seperate angular2 apps for each component.

Thanks in advance, Victor

Community
  • 1
  • 1

0 Answers0