Ember找到关键元素的平均值

时间:2016-06-23 00:54:01

标签: javascript ember.js firebase firebase-realtime-database

我尝试通过选择电影的各个分数并找到平均值来尝试此计算属性。这有点棘手,但这是我到目前为止......

testing: Ember.computed('movie.title', 'movie.rating', function() {
  return this.get('movie.title') + ', ' + this.get('movie.rating');
}),

averageScore: Ember.computed('review.@each.score', function() { //Used to determine each score of review
  return this.get('review').(function(sum, review) {
    return sum += review.get('score');
  }, 0) / this.get('reviews').get('length');
}),

我知道我错过了什么,有什么建议吗?

1 个答案:

答案 0 :(得分:2)

<?php include('session.php'); $username=$_SESSION['username']; $result = pg_query($db,"SELECT * FROM public.antennas WHERE idop IN (SELECT idop FROM public.user WHERE username_u='$username' ) "); return $result; $output = ''; $output .= ' <div class="table-responsive"> <table class="table table-bordered"> <tr> <th width="10%">Id Antennas</th> </tr>'; if(pg_num_rows($result) > 0) { while($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) { $output .= ' <tr> <td>'.$row["id_a"].'</td> <td class="id_a" data-id1="'.$row["id_a"].'" contenteditable>'.$row["id_a"].'</td> <td><button type="button" name="delete_btn" data-id7="'.$row["id_a"].'" class="btn btn-xs btn-danger btn_delete">x</button></td> </tr> '; } $output .= ' <tr> <td></td> <td id="id_a" contenteditable></td> <td><button type="button" name="btn_add" id="btn_add" class="btn btn-xs btn-success">+</button></td> </tr> '; echo 'success'; } else { $output .= '<tr> <td colspan="4">Data not Found</td> </tr>'; echo 'problem'; } $output .= '</table> </div>'; echo $output; ?> 是内置的:

sum