angular 搜索记录保留

 1   #方法1:   点击后退到home后,再点击搜索, locationChangeStart 事件会多次触发。
 2   # $scope.keyword =  $location.search().search
 3   # $scope.search = ()->
 4   #   return if $scope.isSearching
 5   #   return unless $scope.sitetype and $scope.keyword
 6   #   $location.search({search: $scope.keyword})
 7 
 8   #   if $scope.sitetype == 'site'
 9   #     $scope.doSearch()
10   #   else
11   #     $scope.connectSocket($scope.doSearch)
12 
13   # #有关键词的时候,执行搜索任务
14   # if $scope.keyword
15   #   $scope.search()
16 
17   # $rootScope.$on '$locationChangeStart', (e, next, current)->
18   #   console.log 'locationChangeStart...'
19   #   $scope.keyword =  $location.search().search
20   #   $scope.search()
21 
# 方法2 路由: url: '/search/*path' 22 $scope.keyword = $location.path().slice(8) 23 $scope.setPath = (keyword)-> 24 if !keyword 25 keyword = $scope.keyword 26 $location.path('/search/'+keyword)
   #搜索
    if $scope.keyword
       $scope.search()

 

posted @ 2015-09-07 11:12  晚秋ing  阅读(477)  评论(0编辑  收藏  举报