javascript - How to add CSS to dynamically created list from controller in angular js -
i trying create top bar navigation menu in angular js. has drop down menu list dynamic. getting menu db. making call db controller , fetching data there , forming dynamic list css properties there. below code in controller file:
.controller('navcontroller',['$scope','$http','$sce',function($scope,$http,$sce) { $http.get('service/getnavitem.do').then(function(response){ //here doing looping , forming list returned data //lets suppose final list formed after looping through data $scope.navlist="<li><a href='#'>item1</a><ul class='menu'> <li><a href='#'>item2"</a></li></ul></li>";});}]); //view code: navigation.html <div ng-controller='navcontroller'> <ul class="dropdown menu navigation" dropdown-menu> <li> <a href="#">root item>< /a> <ul class="menu" id="navmenu" ng-html-bind="navlist" ></ul> </li> </ul> </div> //app.js code`enter code here` var mainapp=angular.module("myapp",['mm.foundation','ngsanitize']) .directive('navmenu',function(){return{ restrict:'a', replace:true, controller:'navcontroller', templateurl:'app/view/navigation.html' } });
my problem top list getting created , css applied. css not getting applied list dynamically generated controller .
$scope.navlist="<li><a href='#'>item1</a> <ul class='menu'><li><a href='#'>item2"</a></li></ul></li>"
here have mentioned class='menu' , not working.
when directly writing piece of code in view, working, problem want dynamic. can help. new angular js , need helping hand start with. lot in advance. using angular foundation navigation menu.i have included angular-sanitize.js ng-html-bing tag.
Comments
Post a Comment