我想创建一个通知徽章通知徽章的角链接面板。我非常接近,但我遇到了两个问题。第一个是我想要的类从“activeLink”更改为“visitedLink”不切换与NG-点击类。第二个是我只想返回徽章中归类为activeLinks的物品。试图创建AngularJS
https://jsfiddle.net/mvk0851x/9/
标记
<div ng-app='deliverablesApp'>
<div class="notes" ng-controller="NoteCtrl">NOTIFICATIONS <span class="badge">{{noteCount.length}}</span>
<ul>
<li ng-repeat="note in noteCount | limitTo: 4" >
<a ng-click="changeLink = !changeLink"
ng-class="{'activeLink': !changeLink, 'visitedLink': changeLink}"
href="#"
>
{{note.update}}
</a>
<br />
<cite>{{note.date | date: 'medium'}}</cite>
</li>
</ul>
</div>
</div>
控制器
(function(){
var app = angular.module('deliverablesApp', [])
app.controller('NoteCtrl', function($scope){
$scope.noteCount = [
{
update:"Sample text for Note 1",
link:"note-update-link",
date: 1441133965418
},
{
update:"Sample text for Note 2",
link:"note-update-link",
date: 1441129965418
},
{
update:"Sample text for Note 3",
link:"note-update-link",
date: 1440629965418
},
{
update: "Sample text for Note 4",
link:"note-update-link",
date: 1440622965418
},
{
update: "Sample text for Note 5",
link:"note-update-link",
date: 1440621765418
}];
});
})();
您是否希望在点击其中一个项目时防止所有项目中的类别更改? – Girafa