Not sure when to use ng-view or ng-include

I recently used ng-view in a partial view, and it is very similar to using ng-include. Is there a difference between the two: the ng-view directive and ng-include directive, or when is it better to use which?

+6
source share
1 answer

Basically, ng-View creates a new view that works with states or routing, stating that this view gets its own controller and stuff, as if it would be an html file. And ng-include is if you have an html template that you need to show on different views and enable it so as not to duplicate the code.

So, for example, you can ng-include your html header, where you have your navigation, and you can ng-view the registration form or something where you need to have your own route / state and controller

+5
source

All Articles