javascript - Dynamically generated navbar and AngularJS -
i not find easy way explain following, apologize if not clear enough.
i have navigation bar each item category of articles. navigation item read database , can modified back-office.
i categories via angularjs controller :
app.controller('apicontroller', ['$scope', '$http', function($scope, $http) { $http.get('/categories') .success(function(categories) { $scope.categories = categories; }); }]);
<div class="collapse navbar-collapse" id="target-navbar-main"> <ul class="nav navbar-nav"> <li ng-repeat="category in categories"> <a href="/<% category.slug %>" title="<% category.name %>"><% category.name %></a> </li> </ul> </div>
in body of page, using controller articles of given category can't find way make navbar communicate articles controller , pass category of clicked button.
thanks help
i think want api service not controller. in angular controllers aren't meant sending bunch of data between each other. central sets of calls , communications multiple controllers depend on put services. if extract api calls service inject service controllers need deal necessary. without seeing more of code in question it's hard recommend way that.
Comments
Post a Comment