I am new to AngularJS, and - since it is a rather complex and new approach for me, I am a bit confused.
I come from a "classic" background (server-side template languages ββ[for example, Yii, django, Smarty] + some jQuery to make things a bit dynamic). A.
Let's say I have a menu bar (Bootstrap NavBar or something else) - an element that lives outside the contents of the main page, for example:
<body> <div id="menubar"> ... </div> <div class="container"> <div ng-view></div> </div> </body>
Now I would like to make the menu a bit dynamic, that is, add or remove some menu items inside the controller. Using frameworks on the server side and their template system, for example, Yii, I would just have a BaseController class with the $menuItems variable and display it in the menuBar each time, while all controllers would inherit from BaseController so that they could change the elements.
Also, I need a function that handles the searchForm located inside the menu bar. Where should he live?
What is the Angular way for something like this? So far, I have been thinking of creating a custom service or the $rootScope .
javascript angularjs angularjs-scope javascriptmvc
migajek
source share