I am building an application that contains a left menu bar, and a main content view which has the attribute ng-view
. I have configured the router so when the user goes to eg /cars
the html that displays all the cars is used together with the CarListController
. However, I also would like a controller for the menu-bar (which is the same for all views). Is it right to use the ng-controller attribute on that particular element?
And how about using multiple controllers on the same view (Angular view, the content inside ng-view)? I mean, if you have a created a component such as a contact-form where there are code for events on buttons etc. Instead of duplicating this functionality if you use the contact form inside another view, can you use the ng-controller on that html element containing the contact-form? Is that considered bad usage of it?
ng-controller
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.