Search code examples
htmlangularjsangularjs-ng-include

How to use ng-include to switch views in angular?


I have a header.html file. When a div inside it is clicked I want to switch to another view, let's say main.html. I used:

window.location("main.html");

How can I use ng-include to do the same?


Solution

  • For switching between views in angularJS one should use routing. You can use the ngRoute or the ui-router. You should ideally not do that with an ng-include.