我在我创建的checkbox
所有文件中添加了一个。我的分为和。objects
nested list
ngRepeat
objects
folders
files
我想做一些简单的事情,当我选中几个文件和文件夹的框时,我想使用select-option
.
例如
binding
我的list
objects
status
财产有一个严重select-option
的问题 当我尝试在嵌套的几个objects
内部应用它时,问题就更难了。list
我的代码
var webApp = angular.module('webApp', []);
//controllers
webApp.controller ('VotesCtrl', function ($scope, Votes) {
$scope.votes = Votes.getVotesByRatingID(3);
$scope.expand = function(vote) {
console.log("show")
$scope.vote = vote;
$scope.ip = vote.ip;
$scope.date = vote.created;
}
});
//services
webApp.factory('Votes', [function() {
//temporary repository till integration with DB this will be translated into restful get query
var votes = [
{
id: '1',
created: 1381583344653,
updated: '222212',
ratingID: '3',
rate: 5,
ip: '198.168.0.0',
status: 'Pending',
show: false,
folder: [
{
id: '142',
created: 1381583344653,
updated: '222212',
ratingID: '3',
rate: 5,
ip: '198.168.0.0',
status: 'Approved'
},
{
id: '1532',
created: 1381583344653,
updated: '222212',
ratingID: '3',
rate: 5,
ip: '198.168.0.0',
status: 'Pending'
}
]
},
{
ratingID: '2',
file: {
id: '111',
created: 1381583344653,
updated: '222212',
ratingID: '4',
rate: 5,
ip: '198.168.0.1',
status: 'Spam'
}
},
{
ratingID: '3',
file: {
id: '2',
created: 1382387322693,
updated: '222212',
ratingID: '3',
rate: 1,
ip: '198.168.0.2',
status: 'Approved'
}
},
{
ratingID: '3',
file: {
id: '22',
created: 1382387322693,
updated: '222212',
ratingID: '3',
rate: 1,
ip: '198.168.0.3',
status: 'Spam'
}
},
{
ratingID: '3',
file: {
id: '222',
created: 1382387327693,
updated: '222212',
ratingID: '3',
rate: 1,
ip: '198.168.0.4',
status: 'Approved'
}
}
];
votes.getVotesByRatingID = function(ratingID) {
var i, list;
list = [];
for (i = 0; i < votes.length; i += 1) {
if (votes[i].ratingID == ratingID ) {
list.push(votes[i]);
}//end if
}//end outer loop
return list;
};
return votes;
}]);
HTML
<body ng-controller='VotesCtrl'>
<div>
<ul>
<li class="check">
</li>
<li class="created">
<a>CREATED</a>
</li>
<li class="ip">
<b>IP ADDRESS</b>
</li>
<li class="status">
<b>STATUS</b>
</li>
</ul>
<ul ng-repeat="vote in votes">
<li class="check" ng-show="!vote.file">
<input type="checkbox"></input>
</li>
<li class="created">
<a href="#">{{vote.created|date}}</a>
</li>
<li class="ip">
{{vote.ip}}
</li>
<li class="status">
{{vote.status}}
</li>
<li class="check" ng-show="vote.file">
<input type="checkbox"></input>
</li>
<li class="created" ng-click="expand(vote.file)">
<a href="#">{{vote.file.created|date}}</a>
</li>
<li class="ip">
{{vote.file.ip}}
</li>
<li class="status">
{{vote.file.status}}
</li>
<ul class="file" ng-repeat="file in vote.folder">
<li class="check">
<input type="checkbox"></input>
</li>
<li class="created" ng-click="expand(file)">
<a href="#">{{file.created|date}}</a>
</li>
<li class="ip">
{{file.ip}}
</li>
<li class="status">
{{file.status}}
</li>
</ul>
</ul>
</div>
<div class="details">
<h3>Details:</h3>
<div>DATE: {{date|date}}</div>
<div>IP: {{ip|date}}</div>
<div>STATUS:
<select ng-model="vote.status">
<option value="Approved">Approved</option>
<option value="Pending">Pending</option>
<option value="Trash">Trash</option>
<option value="Spam">Spam</option>
</select>
<p>{{vote.status|json}}</p>
</div>
<div>
</body>