Angular ng-repeat inside nav tab not working - angularjs

I'm trying to generate a nav tab dynamically.
This code works:
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" ng-class="{active:isSelected(1)}">
<a ng-click="select(1)" aria-controls="all menu"role="tab">The Menu</a></li>
<li role="presentation" ng-class="{active:isSelected(2)}">
<a ng-click="select(2)" aria-controls="appetizers" role="tab">Appetizers</a></li>
<li role="presentation" ng-class="{active:isSelected(3)}">
<a ng-click="select(3)" aria-controls="mains" role="tab">Mains</a></li>
<li role="presentation" ng-class="{active:isSelected(4)}">
<a ng-click="select(4)" aria-controls="desserts" role="tab">Desserts</a></li>
</ul>
<div class="tab-content">
<ul class="media-list tab-pane fade in active">
<li class="media" ng-repeat="dish in dishes | filter:filtText">
<div class="media-left media-middle">
<a ui-sref="app.dishdetails({id: dish._id})">
<img class="media-object img-thumbnail"
ng-src={{dish.image}} alt="Uthappizza">
</a>
</div>
<div class="media-body">
<h2 class="media-heading">{{dish.name}}
<span class="label label-danger label-xs">{{dish.label}}</span>
<span class="badge">{{dish.price/100 | currency}}</span></h2>
<p ng-show="showDetails">{{dish.description}}</p>
<button ng-show="showFavorites" ng-click="addToFavorites(dish._id)" class="btn btn-xs btn-default pull-right"
type="button">
<i class="fa fa-heart"></i>
</button>
</div>
</li>
</ul>
</div>
Follow the jscode in Menucontroller:
menuFactory.query(
function (response) {
$scope.dishes = response;
$scope.showMenu = true;
},
function (response) {
$scope.message = "Error: " + response.status + " " + response.statusText;
});
$scope.select = function (setTab) {
$scope.tab = setTab;
if (setTab === 2) {
$scope.filtText = "appetizer";
} else if (setTab === 3) {
$scope.filtText = "mains";
} else if (setTab === 4) {
$scope.filtText = "dessert";
} else {
$scope.filtText = "";
}
};
$scope.isSelected = function (checkTab) {
return ($scope.tab === checkTab);
};
Here the code with ng-repeat:
<ul class="nav nav-tabs" role="tablist">
<li ng-repeat="category in categories" role="presentation" ng-class="{active:isSelected(category)}">
<a ng-click="select(category)" aria-controls="category" role="tab">{{category}}</a>
</li>
</ul>
Here new jscode in the controller:
$scope.categories = ["all menu","appetizers","mains","desserts"];
$scope.select = function (setTab) {
$scope.tab = setTab;
if (setTab === "all menu") {
$scope.filtText = "";
} else {
$scope.filtText = setTab;
}
};
$scope.isSelected = function (category){
$scope.currentCategory = category;
};
When I tried with ng-repeat the links in the nav don't work. Previously, I've forgot to replace numbers for strings ( $scope.isSelected = function (checkTab) {return ($scope.tab === checkTab);}; The function select is now calling.
I'd like to put the items in an array and generate the nav dynamically from a list of categories. Finally I replace $scope.filtText = "setTab" to $scope.filtText = setTab and now filtText is working correcty.
Thanks!!

Related

angular JS adding and removing movie to a array of favorites

I'm quite new to angular js and I am having a hard time trying to implement a function who adds a movie to an array of favorites and removes it from the array in case it's already there (difficult part).
Those are my controllers bellow. The SearchController and DetailsController refer to the search.html and details.html respectively, also bellow. Can I get any help?
Thanks in advance
var myControllers = angular.module("myControllers", []);
myControllers.controller(
"SearchController",
function MyController($scope, $http) {
$scope.searchByTitle = function (title) {
$http
.get("http://www.omdbapi.com/?apikey=d4458e16&s=" + title)
.then(function (data) {
$scope.movies = data.data.Search;
});
};
$scope.wishlist = JSON.parse(localStorage.getItem("wishlist"));
}
);
myControllers.controller(
"DetailsController",
function MyController($scope, $http, $routeParams) {
$http
.get("http://www.omdbapi.com/?apikey=d4458e16&i=" + $routeParams.itemId)
.then(function (data) {
$scope.movies = data.data;
});
$scope.favList = JSON.parse(localStorage.getItem("wishlist")) || [];
$scope.isFavorite = false; //JSON.parse(localStorage.getItem("isFavorite")) || false;
$scope.addMovieToFavList = function (item) {
/*if ($scope.favList.includes(item)) {
console.log("movie is on favorites and will be removed");
//$scope.favList.pop(item);
} else {
console.log("movie is not on favorites and will be added");
//$scope.favList.push(item);
}*/
!$scope.isFavorite ? $scope.favList.push(item) : $scope.favList.pop();
$scope.isFavorite = !$scope.isFavorite;
localStorage.setItem("wishlist", JSON.stringify($scope.favList));
//localStorage.setItem("isFavorite", JSON.stringify($scope.isFavorite));
};
}
);
search.html:
<div class="container-fluid">
<h1>Film App<h1>
<div class="row">
<h2>Search</h2>
<input
ng-model="title"
class="form-control"
placeholder="Search for a film"
value="Search"
/>
<button ng-click="searchByTitle(title)" class="btn btn-primary btn-block">
Search for a movie
</button>
<ul class="list-group">
<li ng-repeat="movie in movies | filter:title" class="list-group-item">
<a href="#!/details/{{movie.imdbID}}">
<img ng-src="{{movie.Poster}}" width="30px" />
{{movie.Title}}<span>, {{movie.Year}}</span>
</a>
</li>
</ul>
</div>
</div>
<div class="container-fluid">
<h1>My Favorites<h1>
<ul class="list-group">
<li ng-repeat="favouriteMovie in wishlist" class="list-group-item">
<a href="#!/details/{{favouriteMovie.imdbID}}">
<img ng-src="{{favouriteMovie.Poster}}" width="30px" />
{{favouriteMovie.Title}}<span>, {{favouriteMovie.Year}}</span>
</a>
</li>
</ul>
</div>
details.html:
<div class="container">
<div class="row">
<div class="col-12 mt-3">
<div class="card" ng-model="movies">
<div
class="card-header d-flex align-items-start justify-content-between"
>
<a href="#!">
<button>Back Home</button>
</a>
<button ng-click="addMovieToFavList(movies)">
{{isFavorite==false?'Add to favorites':'Remove from favorites'}}
</button>
<h1 class="card-title my-0">{{movies.Title}}</h1>
<img ng-src="{{movies.Poster}}" />
</div>
<div class="card-body">
<div class="card-text text-secondary">
<h4>Year</h4>
<p>{{movies.Year}}</p>
<h4>Cast</h4>
<p>{{movies.Actors}}</p>
<h4>Plot</h4>
<p>{{movies.Plot}}</p>
<h4>Rating</h4>
<p>{{movies.imdbRating}}/10</p>
</div>
</div>
</div>
</div>
</div>
</div>
You will want to check for the movie via an identifier (like an ID) not by comparing whole objects. So, assuming the object has a property called 'ID' we can check for that. Also, to remove an item from your array, you can use splice
$scope.addMovieToFavList = function(item) {
let index = $scope.favList.findIndex(movie => movie.ID == item.ID);
if (index === -1) {
// movie doesn't exist in favorites yet
$scope.favList.push(item)
$scope.isFavorite = true;
} else {
// movie exists, we will splice it out
$scope.favList.splice(index, 1)
$scope.isFavorite = false
}
localStorage.setItem("wishlist", JSON.stringify($scope.favList));
};

Bookmarking article in ionic app

How to bookmark article in ionic app
<div class="container" on-tap="toggleHeader()" >
<!-- on-tap="toggleHeader()" -->
<div id="test" class="slideItem" ng-class="{'list list-inset-hide': Aindex > $index + 1, 'back-items': Aindex < $index+1}" ng-repeat="Listnews in AllnewsList" ng-style="{'height':'{{hgt}}','z-index': (AllnewsList.length - $index)}" on-swipe-up="swipeUp($event)" on-swipe-down="swipeDown($event)">
<div ng-class="{'satin': Aindex < $index+1, 'not-satin': Aindex != $index}" >
</div>
<ul class="list-unstyled cs-tag-item-grp newsDiv">
<li class="clearfix">
<div class="newsCnt">
<div ng-show="Listnews.ImageUrl !=' ' " class="newsImageContainer">
<img class="newsImage" ng-src="{{Listnews.ImageUrl}}"/>
</div>
<div class="newTitle pLR5">{{Listnews.Heading}}</div>
<div class="newsDisc pLR5">{{Listnews.Para | limitTo: 300}} {{Listnews.Para.length > 300 ? '…':''}}</div>
<div class="newsEdit pLR5"><strong>Starticle</strong> by - {{Listnews.Editor}} / {{Listnews.PublishedDate | date:'dd MMM'}} </div>
<div class="newSrc pLR5" ng-show="Listnews.SourceLink" >more at - <a ng-href="{{Listnews.SourceLink}}" onclick="window.cordova.InAppBrowser.open(this.href, '_blank', 'location=yes'); return false;">{{Listnews.SourceName}}</a>
</div>
<div class="tabs tabs-icon-only" >
<a class="tab-item" >
<a class="button icon ion-share" ng-click="shareAnywhere(Listnews.ImageUrl,Listnews.Heading,Listnews.Para,Listnews.SourceLink)"></a>
</a>
<a class="tab-item">
<a ng-show="!bookmarkstate" class="button icon ion-ios-bookmarks-outline" ng-click="bookmark(true)"></a>
<a ng-show="bookmarkstate" class="button icon ion-ios-bookmarks" ng-click="bookmark(false)"></a>
</a>
<a class="tab-item">
<a class="button icon ion-chatbox-working" ng-click="commentModalopen()"></a>
</a>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
bookmark function
$scope.bookmark = function(state)
{
$scope.info = null;
if(!localStorage.getItem("localnews")){
var book_data = {data: []};
var notID = 0 ;
window.localStorage.setItem("book_data", JSON.stringify(book_data));
window.localStorage.setItem("id", JSON.stringify(notID));
}
$scope.info = JSON.parse(window.localStorage.getItem("book_data"));
$scope.bookmarkstate = state
var page = document.getElementById("localnews").value;
if(page == null)
{
alert("Bookmark Not added");
return;
}
var id = JSON.parse(window.localStorage.getItem("book_data"));
var array = {id:id};
$scope.info.data[$scope.info.data.length] = array;
window.localStorage.setItem("rp_data", JSON.stringify($scope.info));
window.localStorage.setItem("id", JSON.stringify(id + 1));
alert("Bookmark Added")
document.getElementById("Aindex").value =" ";
$scope.getBookmarked();
}

ng-show ng-hide based on $scope variable not working properly

I want to show and hide based on $rootScope variable. I am taking a variable in scope and assigned it true in all functions and all are in same controller, based on that I ng-show..but its not hiding others when switching.
Controller.js:
$rootScope.pcity = true;
if(geolocation.subLocality1 != null){
$rootScope.subLocality=true;
var getCityPopularUsers = function() {
var pageNumber = 0;
$scope.pageSize = 6;
var data = "pageNumber=" + pageNumber + "&pageSize="
+ $scope.pageSize + "&city=" + $routeParams.searchText;
homeService.getPopularUsers(data, function(users) {
$rootScope.cPopUserss = users;
});
};
getCityPopularUsers();
var getSubLocalityPopularTags = function() {
var pageNumber = 0;
$scope.pageSize = 6;
var data = "pageNumber=" + pageNumber + "&pageSize="
+ $scope.pageSize + "&city=" + $routeParams.searchText;
homeService.getSubLocalityPopularTags(data, function(tags) {
$rootScope.cPopsubTags = tags;
});
};
getSubLocalityPopularTags();
}
if(geolocation.city != null) {
$rootScope.city=true;
var getPopularByCityUsers = function() {
var pageNumber = 0;
$scope.pageSize = 6;
var data = "pageNumber=" + pageNumber + "&pageSize="
+ $scope.pageSize + "&city="+ $routeParams.searchText;
homeService.getPopularByCityUsers(data, function(users) {
$rootScope.cPopUsers = users;
});
};
getPopularByCityUsers();
var getCityPopularTags = function() {
var pageNumber = 0;
$scope.pageSize = 6;
var data = "pageNumber=" + pageNumber + "&pageSize="
+ $scope.pageSize + "&city="+ $routeParams.searchText;
homeService.getPopularTagsByCity(data, function(tags) {
$rootScope.cPopTags = tags;
});
};
getCityPopularTags();
}
if(geolocation.state != null) {
$rootScope.state=true ;
var getPopularByStateUsers = function() {
var pageNumber = 0;
$scope.pageSize = 6;
var data = "pageNumber=" + pageNumber + "&pageSize="
+ $scope.pageSize + "&city=" + $routeParams.searchText;
homeService.getPopularByStateUsers(data, function(users) {
$rootScope.cPopStateUsers = users;
});
};
getPopularByStateUsers();
var getStatePopularTags = function() {
var pageNumber = 0;
$scope.pageSize = 6;
var data = "pageNumber=" + pageNumber + "&pageSize="
+ $scope.pageSize + "&city="+ $routeParams.searchText;
homeService.getStatePopularTags(data, function(tags) {
$rootScope.cPopStateTags = tags;
});
};
getStatePopularTags();
}
This is my index.jsp:
<div class="popular-account-list list-home-aside" ng-show="pcity == true && subLocality == true ">
<ul class="nav">
<li class="active icon bb-users">Popular Account</li>
<li ng-repeat="user in cPopUserss | limitTo : 4">
<figure class="clearfix" ng-show="loggedInUser.id!=user.id">
<div class="home-acc-imgsize" ng-if="user.photo != null">
<a href="#!/profile/user/{{user.id}}">
<img ng-src="settings/dp?username={{user.username}}&photoId={{user.photo.id}}&fileName={{user.photo.fileName}}"
alt="profile-img" class="img-responsive" style="height:100%;width:100%">
</a>
</div>
<div class="home-acc-imgsize" ng-if="user.photo == null">
<a href="#!/profile/user/{{user.id}}">
<img src="images/userimage.jpg" alt="profile-img" class="img-responsive">
</a>
</div>
<figcaption>
<p ng-show="user.domainName == null">
{{user.firstName}} {{user.lastName}}
</p>
<p ng-show="user.domainName != null">
{{user.username}}
</p>
<p><span>{{user.designation}}</span></p>
<button class="btn btn-following btn-xs" role="button"
ng-show="isFollowed == false || isFollowed == 'false' && user.id != loggedInUser.id"
ng-click="follow(user.id)">Follow</button>
<button class="btn btn-following btn-xs" role="button" ng-show="isFollowed == 'true'"
ng-click="removeFollow(user.id)">Following</button>
</figcaption>
</figure>
</li>
<li>More Accounts <span class="caret"></span></li>
</ul>
</div><!-- eo popular-account-list-list -->
<div class="popular-account-list list-home-aside" ng-show="pcity == true && city == true">
<ul class="nav">
<li class="active icon bb-users" >Popular Account</li>
<li ng-repeat="user in cPopUsers | limitTo : 4">
<figure class="clearfix" ng-show="loggedInUser.id!=user.id">
<div class="home-acc-imgsize" ng-if="user.photo != null">
<a href="#!/profile/user/{{user.id}}">
<img ng-src="settings/dp?username={{user.username}}&photoId={{user.photo.id}}&fileName={{user.photo.fileName}}"
alt="profile-img" class="img-responsive" style="height:100%;width:100%">
</a>
</div>
<div class="home-acc-imgsize" ng-if="user.photo == null">
<a href="#!/profile/user/{{user.id}}">
<img src="images/userimage.jpg" alt="profile-img" class="img-responsive">
</a>
</div>
<figcaption>
<p ng-show="user.domainName == null">
<a href="#!/profile/user/{{user.id}}">{{user.firstName}} {{user.lastName}}
</a>
</p>
<p ng-show="user.domainName != null">
{{user.username}}
</p>
<p><span>{{user.designation}}</span></p>
<button class="btn btn-following btn-xs" role="button"
ng-show="isFollowed == false || isFollowed == 'false' && user.id != loggedInUser.id"
ng-click="follow(user.id)">Follow</button>
<button class="btn btn-following btn-xs" role="button" ng-show="isFollowed == 'true'"
ng-click="removeFollow(user.id)">Following</button>
</figcaption>
</figure>
</li>
<li>More Accounts <span class="caret"></span>
</li>
</ul>
</div><!-- eo popular-account-list-list -->
<div class="popular-account-list list-home-aside" ng-show="pcity == true && state == true ">
<ul class="nav">
<li class="active icon bb-users">Popular Account</li>
<li ng-repeat="user in cPopStateUsers | limitTo : 4">
<figure class="clearfix" ng-show="loggedInUser.id!=user.id">
<div class="home-acc-imgsize" ng-if="user.photo != null">
<a href="#!/profile/user/{{user.id}}">
<img ng-src="settings/dp?username={{user.username}}&photoId={{user.photo.id}}&fileName={{user.photo.fileName}}"
alt="profile-img" class="img-responsive" style="height:100%;width:100%">
</a>
</div>
<div class="home-acc-imgsize" ng-if="user.photo == null">
<a href="#!/profile/user/{{user.id}}">
<img src="images/userimage.jpg" alt="profile-img" class="img-responsive">
</a>
</div>
<figcaption>
<p ng-show="user.domainName == null">
<a href="#!/profile/user/{{user.id}}">{{user.firstName}} {{user.lastName}}
</a>
</p>
<p ng-show="user.domainName != null">
{{user.username}}
</p>
<p><span>{{user.designation}}</span></p>
<button class="btn btn-following btn-xs" role="button"
ng-show="isFollowed == false || isFollowed == 'false' && user.id != loggedInUser.id"
ng-click="follow(user.id)">Follow</button>
<button class="btn btn-following btn-xs" role="button" ng-show="isFollowed == 'true'"
ng-click="removeFollow(user.id)">Following</button>
</figcaption>
</figure>
</li>
<li>More Accounts <span class="caret"></span>
</li>
</ul>
</div><!-- eo popular-account-list-list -->
In controller if I use $scope instead of rootScope nothing works only, so where i am going wrong.Please help

Angular how to redirect to a tab

I have a page which has got 5 tabs. There is another page which contains the links pointing to these tabs. Whenever a user clicks a link on this page, corresponding tab should be opened on angular application page.
The tab are working fine when user manunally clicks on a tab but I am unable to find how can I select a tab by default.
Add in app.js:
$routeProvider.when('/trend', {
templateUrl:'partials/trend.html'
}).when('/deepdive', {
templateUrl:'partials/deepdive.html'
}).when('/driversNdrainers', {
templateUrl:'partials/DriversNDrainers.html'
}).when('/timeline', {
templateUrl:'partials/timeline.html'
}).otherwise("/trend");
index page:
<div header></div>
<div class="row">
<div class = "col-md-12" ng-include="'partials/home.html'"></div>
</div>
<div footer></div>
The home controller creates the tabs dynamically.
Home.html
<div class="" fade-in ng-controller="HomeCtrl">
<ul class="nav nav-pills">
<li ng-class="tabClass(tab)" ng-repeat="tab in tabs" tab="tab"><a href="{{tab.link}}" id="{{tab.id}}"
ng-click="setSelectedTab(tab)">{{tab.label}}</a></li>
</ul>
<div ng-view></div>`enter code here`
Controller:
var homectrl = myApp.controller('HomeCtrl', ['$scope', '$routeParams', '$location','$state', function ($scope, $routeParams,$location,$state) {
$scope.tabs = [
{ link : '#/trend', label : 'Trend', id: "trendLink"},
{ link : '#/deepdive', label : 'Deep Dive' , id:"deepdriveLink"},
{ link : '#/driversNdrainers', label : 'Drivers & Drainers', id:"ddLink" },
{ link : '#/timeline', label : 'Timeline' , id: "timelineLink"},
{ link : '#/zoomin', label : 'Zoom In', id: "zoominLink" }
];
$scope.selectedTab = $scope.tabs[0];
$scope.setSelectedTab = function(tab) {
$scope.selectedTab = tab;
};
$scope.tabClass = function(tab) {
return $scope.selectedTab == tab? "active": "";
};
angular.element(document).ready(function () {
$.each($scope.tabs,function(i){
if(this.link==location.hash){
$scope.setSelectedTab(this);
//$state.go("/trend");
return;
}
});
});
}]);
What I see here is that the tab is selected but the content inside tab is not loaded.
Your code inside jQuery is not executed in Angular's digest cycle. Try adding $scope.$apply(); right after $scope.setSelectedTab(this);
To understand why you should do this read: "Scope Life Cycle" at https://docs.angularjs.org/guide/scope
Here is the solution you can refer to stackblitz
I had to do some modification in its function to achieve the result as per my requirement.
modified solution:
moveToSelectedTab(tabName: string) {
for (let i = 0; i < document.querySelectorAll('[aria-selected]').length; i++) {
let element = document.querySelectorAll('[aria-selected="false"]')[i];
if (element != undefined) {
if ((<HTMLElement>document.querySelectorAll('[aria-selected="false"]')[i]).innerHTML == tabName) {
(<HTMLElement>document.querySelectorAll('[aria-selected="false"]')[i]).click();
}
}
}}
HTML
<ul class="nav nav-tabs" id="editorTab" role="tablist">
<li class="nav-item active" role="presentation">
<a class="nav-link active" id="bannerArea-tab" data-toggle="tab" href="#bannerArea" role="tab"
aria-controls="bannerArea" aria-selected="true">General Information</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="cardArea-tab" data-toggle="tab" href="#cardArea" role="tab"
aria-controls="cardArea" aria-selected="false">Banner Content</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="mainArea-tab" data-toggle="tab" href="#mainArea" role="tab"
aria-controls="mainArea" aria-selected="false">Main Content</a>
</li>
</ul>
<div class="tab-content" id="editorTabContent">
<div class="tab-pane fade show active col-sm-12" id="bannerArea" role="tabpanel" aria-labelledby="bannerArea-tab">
<div class="form-group">
</div>
<div class="text-right margin-top-xl">
<button class="btn-icon-confirm" (click)="moveToSelectedTab('Banner Content')">Next<i class="material-icons">arrow_forward</i></button>
</div>
</div>
<div class="tab-pane fade show active col-sm-12" id="cardArea" role="tabpanel" aria-labelledby="cardArea-tab">
<div class="form-group">
</div>
<div class="text-right margin-top-xl">
<button class="btn-icon-confirm" (click)="moveToSelectedTab('Main Content')">Next<i class="material-icons">arrow_forward</i></button>
</div>
</div>
<div class="tab-pane fade col-sm-12" id="mainArea" role="tabpanel" aria-labelledby="mainArea-tab">
<div class="text-right margin-top-xl">
<button class="btn-icon-confirm" (click)="moveToSelectedTab('General Information')"><i class="material-icons">check</i></button>
</div>
</div>
</div>

Show and hide elements of ng-repeat cycle

Here is my HTML:
<ul class="no-bullet">
<li ng-repeat="(group, count) in info.info">
<a href="#" ng-click="getQuestions(group)"
ng-mouseenter="showGroupPanel()" ng-mouseleave="hideGroupPanel()"
>{{group}} ({{count}}) </a>
<div class="group_panel" ng-show="hoveringGroup">
<i class="fa fa-check"></i>
<i class="fa fa-folder-o"></i>
</div>
</li>
And here is my JS:
$scope.hoveringGroup = false;
$scope.showGroupPanel = function() {
$scope.hoveringGroup = true;
}
$scope.hideGroupPanel = function() {
$scope.hoveringGroup = false;
}
When user mouseover one of elements of the list additional div (group_panel) is displayed. But it is displayed for all elements of the list. How can I fix it to display "group-panel" div only for one element (mouseovered) of the list?
Simplest way : use ng-repeat's isolate scope. (hoveringGroup will be a separate variable for each ng-repeat iteration)
<ul class="no-bullet">
<li ng-repeat="(group, count) in info.info">
<a href="#" ng-click="getQuestions(group)"
ng-mouseenter="hoveringGroup = true" ng-mouseleave="hoveringGroup = false"
>{{group}} ({{count}}) </a>
<div class="group_panel" ng-show="hoveringGroup">
<i class="fa fa-check"></i>
<i class="fa fa-folder-o"></i>
</div>
</li>
You could also store the information in your repeated item :
<ul class="no-bullet">
<li ng-repeat="info in info.info">
<a href="#" ng-click="getQuestions(info.group)"
ng-mouseenter="showGroupPanel(info)" ng-mouseleave="hideGroupPanel(info)"
>{{info.group}} ({{info.count}}) </a>
<div class="group_panel" ng-show="info.hoveringGroup">
<i class="fa fa-check"></i>
<i class="fa fa-folder-o"></i>
</div>
</li>
$scope.showGroupPanel = function(info) {
info.hoveringGroup = true;
}
$scope.hideGroupPanel = function(info) {
info.hoveringGroup = false;
}
var app = angular.module('app', []);
app.controller('homeCtrl', function($scope) {
$scope.info = {
info: [{
id: 1
}, {
id: 2
}, {
id: 3
}
]
}
$scope.hoveringGroup = false;
$scope.showGroupPanel = function(level) {
level.hoveringGroup = true;
}
$scope.hideGroupPanel = function(level) {
level.hoveringGroup = false;
}
$scope.createlevel = function(count, level) {
return angular.copy(count, level)
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<div ng-app="app">
<div ng-controller="homeCtrl">
<ul class="no-bullet">
<li ng-repeat="(group, count) in info.info" ng-init="level =createlevel(count,level)">
{{group}} ({{count}})
<div class="group_panel" ng-show="level.hoveringGroup">
<i class="fa fa-check"></i>
<i class="fa fa-folder-o"></i>
</div>
</li>
</ul>
</div>
</div>

Resources