mirror of
https://github.com/wu736139669/vczero.github.io.git
synced 2026-08-05 06:23:38 +00:00
add search
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
|
||||
app.directive('loading', function(){
|
||||
var str = '<div id="loading" ng-show="isNoLoaded"><img src="../imgs/loading.gif" /></div>';
|
||||
return {
|
||||
restrict: 'AE',
|
||||
template: str,
|
||||
replace: true
|
||||
};
|
||||
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
/*初始化的结果*/
|
||||
app.controller('movieListController', function($rootScope, movieList){
|
||||
if(!$rootScope.keywordsObj.movie){
|
||||
$rootScope.keywordsObj.movie = '笑傲江湖';
|
||||
$rootScope.keywordsObj.movie = '幸福';
|
||||
}
|
||||
movieList.getData($rootScope.keywordsObj.movie);
|
||||
});
|
||||
@@ -19,7 +19,7 @@ app.controller('SearchController', function($scope, $rootScope, $location, bookL
|
||||
if(keywords){
|
||||
$rootScope.keywordsObj.movie = keywords;
|
||||
}
|
||||
movieList.getData($rootScope.keywordsObj.music);
|
||||
movieList.getData($rootScope.keywordsObj.movie);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -1,10 +1,5 @@
|
||||
var app = angular.module('app', ['ui.router']);
|
||||
|
||||
addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
|
||||
function hideURLbar(){
|
||||
window.scrollTo(0,1);
|
||||
}
|
||||
|
||||
/*$rootScope的相关配置*/
|
||||
app.run(function($rootScope){
|
||||
$rootScope.version = '0.1';
|
||||
|
||||
@@ -4,14 +4,14 @@ app.factory('movieList', function($rootScope, $http, ServiceConfig){
|
||||
var _MovieList = {
|
||||
getData: function(keywords){
|
||||
$rootScope.isNoLoaded = true;
|
||||
$http.jsonp(ServiceConfig.movie_search + '?callback=movieSearch&count=10&q=' + keywords);
|
||||
$http.jsonp(ServiceConfig.movie_search + '?callback=movieSearch&count=5&q=' + keywords);
|
||||
|
||||
window.movieSearch = function(data){
|
||||
$rootScope.isNoLoaded = false;
|
||||
if(data.subjects && data.subjects.length){
|
||||
$rootScope.movieList = data.subjects;
|
||||
}
|
||||
console.log(data.subjects)
|
||||
console.log(data.subjects);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user