角度js数据绑定未显示

时间:2016-02-28 10:57:38

标签: angularjs codeigniter

这是我的控制器:

  $scope.openReview = function(recipe_id){
  console.log(recipe_id);
  CommentList.getRecipeDetails(recipe_id);

     $scope.newComment.recipeID = recipe_id;
     CommentList.all($scope.newComment.recipeID).then(function(payload) {
     $scope.feedbackdata = payload;
     console.log(payload);
 });

}

我的观点:

<ion-view view-title="Reviews" enable-menu-with-back-views="true">
<ion-content>
<div class="items item item-avatar" ng-repeat="comment in feedbackdata">
  <h2>{{comment.firstname}} {{comment.lastname}}</h2>
  <p>{{comment.comment}}</p>
</div>
</ion-content>
</ion-view>

我想要检索数据。我的控制台已经显示,但在我的视图中没有显示任何内容。

0: Object
    comment: "asdfgh"
    firstname: "Ana"
    lastname: "Luna"
    __proto__: Object
1: Object
    comment: "qwerty"
    firstname: "Andrea"
    lastname: "Swift"

以下是我的附加代码

模型

public function feedback_data($recipe_id)
{
    $this->db->select('feedback.comment,user.firstname,user.lastname');
    $this->db->from('feedback');
    $this->db->join('user','user.user_id = feedback.user_id');
    $this->db->where('feedback.recipe_id', $recipe_id);
    $query = $this->db->get();
    return $query->result_array();
}

public function get_feedback_data()
{
    $postdata = json_decode(file_get_contents("php://input"));
    $feedback = $this->User_model->feedback_data($postdata);
    echo json_encode($feedback);
}

服务

        all: function(recipe_id) {
      return $http.post("http://localhost/admin-recipick/api/Main/get_feedback_data", recipe_id).then(function(result){
        return result.data;
      })
    },

请帮帮我..请帮帮我

2 个答案:

答案 0 :(得分:0)

 <h2>{{comment.firstname}} {{comment.lastname}}</h2>
 <p>{{comment.comment}}</p>

只需删除此行即可      

{{comment.feedback_id}}

因为我认为feedback_id不在绑定数组中

答案 1 :(得分:0)

你必须以这种形式的[{id:1,ima:gh.jpg},{id=2,ima:jh.jpg}]对象形式的数组中获取数据