0
私は今日の誕生日をチームリストから表示したいと思います。私は誕生日(例えば、16/12/1999)と名前を含むデータを持っています。私はこれを使って次の出産を表示しています。しかし、私は今日の誕生日ブロックを表示したい。助けてください今日の誕生日は角を使用して表示
<script>
function birthdayCtrl($scope){
$scope.friends=[
{name:'Pete','birthday':"12/25/1983"},
{name:'Sarah','birthday':"02/14/1985"},
{name:'James','birthday':"01/15"},
{name:'Lilly','birthday':"04/01/1975"},
{name:'John','birthday':"08/07/1955"},
]
$scope.friends.forEach(function(data){
var day = data.birthday.split("/")
var currentYear = new Date().getFullYear();
var birthdayDate = new Date(currentYear, day[0] - 1, day[1])
var now = new Date().valueOf();
if (birthdayDate.valueOf() < now){
birthdayDate.setFullYear(currentYear+1)
}
data.fromNow = birthdayDate.valueOf() - now;
})
}
</script>
<body ng-controller="birthdayCtrl">
<h1>Upcoming Birthdays</h1>
<table>
<th>No.</th>
<th>Name</th>
<th>Birthday</th>
<tr ng-repeat="friend in friends| orderBy:'fromNow' ">
<td>{{$index}}</td>
<td>{{friend.name}}</td>
<td>{{friend.birthday}}</td>
</tr>
</table>
<style>
table td,table th{
border: thin solid #eaeaea;
width:150px;
padding:3px 5px;
</style>
</body>
あなたは瞬間のJSのようなライブラリを使用して考えがありますか? – nipuna777
質問していることを明確にするために、質問の言葉を再言えますか?友人の誕生日が今日の日付に表示されている場合、その誕生日を表示したいと思っているようですね。 –
ここにあなたが望むものを示すフィドルです:http://jsfiddle.net/c6BfQ/3/ – Matheno