0
我要求TheMovieDB提供的内容在我的网站上显示它(标题,图片,发布日期),并将该内容存储在我的数据库中。我想知道是否可以按日期订购。如何按日期订购?
我知道那里有| orderBy:'date'"
,但我不知道如何在我的网站上使用它。
会有两种情况,我希望按日期排序。
第一种情况是当用户执行搜索操作时,他们可以键入电影标题,我的搜索功能将从TheMovieDB中检索所有标题(以及发布日期)并将它们显示在ul
中。
%div{"ng-controller" => "searchCtrl", :id => "container_search"}
%input{"ng-change" => "search(searchquery)", "ng-model" => "searchquery", "ng-model-options" => "{ debounce: 500 }", :id => "search_input", :placeholder => "Search a movie!", "ng-keyup" => "clear_results()"}
%ul#showresults
%li.search_results{"ng-repeat" => "movie in movieList"}
.addmovie{"ng-click" => "addMovie()"}
%span
Add Movie
%img.poster{"ng-src" => "http://image.tmdb.org/t/p/w500/{{ movie.poster_path }}"}
%span.title
{{ movie.original_title }}
%span.release
{{ movie.release_date }}
TheMovieDB HTTP请求的输出是这样的,
angular.callbacks._6({"page":1,"results":[{"adult":false,"backdrop_path":"/jSNIAKD5pCyhjgJL9HZ3hsu19yD.jpg","genre_ids":[28,12,80],"id":206647,"original_language":"en","original_title":"SPECTRE","overview":"A cryptic message from Bond’s past sends him on a trail to uncover a sinister organization. While M battles political forces to keep the secret service alive, Bond peels back the layers of deceit to reveal the terrible truth behind SPECTRE.","release_date":"2015-10-26","poster_path":"/zHx5KaKaQdZZnEUgtjcIdNcB3ka.jpg","popularity":1.279592,"title":"SPECTRE","video":false,"vote_average":7.0,"vote_count":61}],"total_pages":1,"total_results":1})
而第二个情况是当用户检查他的头版就说明他加入到他的页面中的所有电影片名。
%div{"ng-repeat" => "movie in movies", :class => "movie_container"}
%h2
{{ movie.release_date }}
%img.poster{"ng-src" => "{{ movie.image }}"}
.movie-info
%h2
{{ movie.title }}
%a{"ng-click" => "deleteMovie(movie)"}delete
这些是在它们被创建时排序,而不是在它们被释放时排序。我的JSON文件的输出是这样的,
{"id":51,"created_at":"2015-08-27T13:05:19.074Z","updated_at":"2015-08-27T13:05:19.074Z","user_id":1,"image":"http://image.tmdb.org/t/p/w500//uereni1nSrWb6OWiJhK7FrW4pcd.jpg","title":"\n Batman v Superman: Dawn of Justice\n ","release_date":"\n 2016-03-25\n "}]
'orderBy:'release_date'这实际上有效。没想到答案会很明显。 –