脚本和控制台日志在通过nodejs运行时不返回任何内容

时间:2018-01-01 20:46:11

标签: javascript angularjs node.js mongodb meteor

我在尝试让这个脚本工作时遇到了一些麻烦!

在我的路线中,我有以下几行代码:

  .state('app.subcats', {
    cache: false,
    url: '/subcat/:idcat',
    views: {
      'menuContent@app': {
        templateUrl: 'client/templates/shop/subcat.html',
        controller: 'SubcatsCtrl as vm' 
      }
    }
  })  

这是脚本subcat.js:

import { _meteorAngular } from 'meteor/angular';
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';

angular
    .module('salephone')
    .controller('SubcatsCtrl', SubcatsCtrl);

function SubcatsCtrl (
                    $scope,
                    $stateParams,
                    $state,
                    $reactive,
                    $rootScope,
                    $ionicLoading,
                    $ionicHistory,
                    $ionicViewSwitcher,
                    $timeout
                  ){
  $reactive(this).attach($scope);
  console.log("test");
  var self = this;
  this.subcats = [];
  this.contentLoaded = false;
  self.noPosts = "";

  if( window.localStorage.getItem('subcats') ){
    this.productss = JSON.parse( window.localStorage.getItem('subcats') );
  }

  //Variables for infinite scroll.
  self.loaded = 100;
  self.limit = self.loaded;

  console.log("test 1");

  this.getSubcat = function(){

    //Load products on scroll.
    this.subscribe('SubcatMain', () => [ $stateParams.idcat, self.loaded ], {
      onReady: function() {
        //Get count of all Products in server.
        //Method is located at tapshop/lib/methods/app_methods.js
        Meteor.call('allSubcats', $stateParams.idcat, function(err, count) {
            self.allsubcats = count;
          self.limit = self.loaded;

          self.subcats = Products.find({
            catLinkID : $stateParams.idcat,
            listingsCount: { $gt: 0 }
          },{
            sort: {
              productOffersCount: -1,
              listingsCount: -1,
              name: 1
            },
            limit: self.limit
          }).fetch();

          window.localStorage.setItem('subcats', JSON.stringify(self.subcats) );

          self.contentLoaded = true;
          self.noPosts = 'No posts available.';

          $ionicLoading.hide();
          return;        
        });
      },
      onStop: function(err){
        console.log("test 2");
        if(err){
          self.contentLoaded = true;
          self.noPosts = "No internet connection.";
          console.log(JSON.stringify(err)); // <- nothing here
          return;
        }
      }
    });
  }

  this.getSubcat();

  ...

当我启动脚本时,我只得到:

No internet connection.

没有关于错误消息的内容!并且,我认为我没有出错的地方!

有人可以告诉我这个问题吗?

我正在研究IONIC V1 + METEOR。

请注意,数据库中也没有返回任何内容!

0 个答案:

没有答案