對於每個'條目中的條目',我有一個按鈕,將ng-show切換爲true並顯示有關條目的詳細信息。目前,此代碼切換到ng-show = true的每個條目。我希望每個按鈕,僅切換的細節它定位於入門AngularJS切換顯示所有條目
我的觀點:。
<h1>Listing Projects</h1>
<ul class="unstyled">
<li ng-repeat="entry in entries" ng-init="entryClass=isClass(entry.isProject)">
<ul class="unstyled">
<li>
<div class="alert" ng-class="entryClass">
<h3>{{entry.title}}</h3>
<button ng-click="toggleShow()">Details</button>
<div style="background-color:#000000; min-width:100px; min-height:100px;" ng-show="showThis">
</div>
</div>
</li>
</ul>
</li>
</ul>
的AngularJS:
app = angular.module("Resume", ["ngResource"])
app.factory "Entry", ["$resource", ($resource) ->
$resource("/entries")
]
@EntryCtrl = ["$scope", "Entry", ($scope, Entry) ->
$scope.entries = Entry.query()
$scope.showThis = false
$scope.isClass = (isProject) ->
if isProject == true
$scope.myVar = "project alert-info"
else
$scope.myVar = "tech alert-success"
$scope.toggleShow = ->
if $scope.showThis == false
$scope.showThis = true
else
$scope.showThis = false
]
感謝您的幫助。我選擇了第二個選項,因爲它需要的代碼量最少。也許你可以幫我解決另一個角度問題。謝謝! http://stackoverflow.com/questions/15227715/angularjs-multiple-draggable-items-causes-jump-on-initial-move – 2013-03-06 10:56:53