add search page in search web app

This commit is contained in:
wlh
2014-12-12 16:20:05 +08:00
parent f05ae96998
commit 98c562ee8e
9 changed files with 127 additions and 42 deletions
-28
View File
@@ -1,28 +0,0 @@
/*搜索*/
var SearchController = function($scope, $rootScope, $location, bookList, musicList, movieList){
var path = $location.path();
$scope.search = function(){
var keywords = $scope.keywords;
if(path.indexOf('/book') !== -1 || path === '/'){
if(keywords){
$rootScope.keywordsObj.book = keywords;
}
bookList.getData($rootScope.keywordsObj.book);
}else if(path.indexOf('/music') !== -1 || path === '/music'){
if(keywords){
$rootScope.keywordsObj.music = keywords;
}
musicList.getData($rootScope.keywordsObj.music);
}else if(path.indexOf('/movie') !== -1 || path === '/movie'){
if(keywords){
$rootScope.keywordsObj.movie = keywords;
}
movieList.getData($rootScope.keywordsObj.movie);
}
};
};
SearchController.$inject = ['$scope', '$rootScope', '$location', 'bookList', 'musicList', 'movieList'];
app.controller('SearchController', SearchController);
+18
View File
@@ -125,5 +125,23 @@ app.config(['$stateProvider', '$urlRouterProvider',function($stateProvider, $url
controller: ''
}
}
})
.state('search',{
url: '/search/:type',
views:{
header:{
templateUrl: '../html/views/search.html',
controller: 'Search'
},
container:{
templateUrl: '',
controller: ''
},
footer:{
templateUrl: '',
controller: ''
}
}
});
}]);
+29
View File
@@ -0,0 +1,29 @@
/*负责搜索结果的导向*/
var Search = function($scope, $rootScope, $location, bookList, musicList, movieList){
var path = $location.path();
$rootScope.isNoLoaded = false;
//跳回列表页
$scope.search = function(){
var keywords = $scope.keywords;
if(path.indexOf('/book') !== -1){
if(keywords){
$rootScope.keywordsObj.book = keywords;
}
$location.path('/book');
}else if(path.indexOf('/music') !== -1){
if(keywords){
$rootScope.keywordsObj.music = keywords;
}
$location.path('/music');
}else if(path.indexOf('/movie') !== -1){
if(keywords){
$rootScope.keywordsObj.movie = keywords;
}
$location.path('/movie');
}
};
};
Search.$inject = ['$scope', '$rootScope', '$location', 'bookList', 'musicList', 'movieList'];
app.controller('Search', Search);
+20
View File
@@ -0,0 +1,20 @@
/*仅负责搜索页面的打开*/
var SearchController = function($scope, $rootScope, $location){
var path = $location.path();
$scope.goToSearch = function(){
if(path.indexOf('/book') !== -1 || path === '/'){
$location.path('/search/book');
}else if(path.indexOf('/music') !== -1 || path === '/music'){
$location.path('/search/music');
}else if(path.indexOf('/movie') !== -1 || path === '/movie'){
$location.path('/search/movie');
}
};
};
SearchController.$inject = ['$scope', '$rootScope', '$location'];
app.controller('SearchController', SearchController);