Wikipedia:Reference desk/Archives/Computing/2022 June 4

= June 4 =

How can Angular know the build mode of an ASP.NET MVC application?
At work I am developing a system that is based on ASP.NET MVC. Part of the system uses Angular on the front end. The ASP.NET MVC controller serves a view page that has an Angular app declaration, which causes the Angular component to load. The templates and code files for the Angular component are stored in the ASP.NET MVC application's  directory.

The thing here is that Angular is in development mode by default, but it should call  to go into production mode in release builds shipped to customers. This caused a problem that how can Angular know if the system was built in release mode. I solved this by having  in Angular call an ASP.NET MVC controller method via AJAX, and this controller method simply returns a static boolean value which is determined by   ...   ...  . This works, but I was wondering if there was an easier way to do this completely at compile time, so the Angular code would not have to make an AJAX request each time. Is there one? J I P &#124; Talk 20:24, 4 June 2022 (UTC)