Switch between mobile or desktop template using condition in templateUrl (Angular 7)
问题 I want to switch between a desktop and mobile template depending on the screen width to ensure my application is responsive. I am trying to do the following: @Component({ selector: 'app-root', templateUrl: "./" + (window.innerWidth < 768) ? "app.component.html" : "app.component.mobile.html", styleUrls: ['./app.component.css'] }) However, this is not working. Instead of the template loading, the string, "app.component.html" , appears on the screen instead. What is even more interesting is that