add search

This commit is contained in:
wlh
2014-12-12 00:17:22 +08:00
parent 38cb1e5dfc
commit 4ce604283e
19 changed files with 376 additions and 27474 deletions
+10
View File
@@ -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 -1
View File
@@ -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);
});
+1 -1
View File
@@ -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);
}
};
});
-5
View File
@@ -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';
+2 -2
View File
@@ -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);
};
}
};