meteorhacks / search-source

Reactive Data Source for Search
MIT License
145 stars 33 forks source link

Exception in delivering result of invoking 'search.source': TypeError: Cannot read property 'data' of undefined #36

Open mattiLeBlanc opened 9 years ago

mattiLeBlanc commented 9 years ago

Hi,

I am trying to use Searchsource in my Meteor Angular project. The implementation as I used to do it in my meteor only project with Blaze seems to work, however on page load I get this error message: Exception in delivering result of invoking 'search.source': TypeError: Cannot read property 'data' of undefined

My code:

angular.module( 'myapp' ).controller 'feedListCtrl',
  ($scope, $meteor, $state , $stateParams ) ->

    feedName = $stateParams.term
    limit = 30
    sort =
      'publishedDate': -1

    $scope.channelData = null
    $scope.episodes = null
    $scope.channelLoading = true
    $scope.episodeCount = 0
    $scope.activeListItem = null

    $scope.channel  = $meteor.subscribe( 'channelMetaByName', feedName )
    $scope.feed     = $meteor.subscribe( 'feedsByChannelName', feedName, sort )

    # $scope.feed     = $meteor.collection( Feeds, false ).subscribe( 'feedsByChannelName', feedName, sort )
    # $scope.channel  = $meteor.collection( Channels, false ).subscribe( 'channelMetaByName', feedName )

    $scope.channel.then ( subscription )->
      $scope.channelLoading   = false
      $scope.channelData      = Channels.findOne().channelMeta

    $scope.feed.then ( subscription ) ->
      $scope.episodes = Feeds.find().fetch()
      $scope.episodeCount = Feeds.find().count()

    $meteor.autorun $scope, ->
      console.log("search", $scope.getReactively( 'search' ) )
      FeedSearch.search $scope.getReactively( 'search' )

Besides the error message, the search does work in the autorun part. When I call getData I do get the filtered results. Any idea what is going wrong?

valorloff commented 8 years ago

+1 i have same error in meteor-blaze