【问题标题】:Debugging the unknown error. Angular app.js调试未知错误。角应用程序.js
【发布时间】:2016-08-10 04:25:50
【问题描述】:

我正在尝试让我的 ionic app.js 与我的新工厂一起运行,但在定位错误时遇到了问题。我不确定在哪里,但它可能是一个简单的错误。如果你能帮助我,那将意义重大。索引中没有错误,我有正确的 ng-app。谢谢

没有错误:它只是一个空白屏幕:/ 我该如何调试?

var app = angular.module('starter', ['allmystuff']);

(function() {
  'use strict';

  app

    .run(runFunction)
    .config(configFn)
    .controller('MainCtrl', MainCtrl)
    .factory('myService', myService);


  function runFunction($ionicPlatform) {
    $ionicPlatform.ready(function() {
      if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
        cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        cordova.plugins.Keyboard.disableScroll(true);

      }
      if (window.StatusBar) {
        // org.apache.cordova.statusbar required
        StatusBar.styleDefault();
      }
    })
  }


  MainCtrl.$inject = ['$scope', 'myService','$localStorage'];

  function MainCtrl($scope, myService, $localStorage) {
    function getSuccess(response) {
      $scope.items = response.data;
    }

    function getError(response) {
      console.log('Of course an error since the url is a invalid, but it should work with a valid url!');
    }

    myService.getAll()
      .then(getSuccess)
      .catch(getError);
  }

  function myService($http) {
    var factory = {
      getAll: getAll
    };

    return factory;

    function getAll() {
      return $http.get(""); 
    }
  }


function configFn($stateProvider, $urlRouterProvider) {

  $stateProvider

  // setup an abstract state for the tabs directive
    .state('tab', {
    url: '/tab',
    abstract: true,
    templateUrl: 'templates/tabs.html'
  })

    .state('login', {
      url: "/login",
      cache: false,
      controller: 'AccountCtrl',
      templateUrl: "templates/login.html"
    })

  .state('tab.account', {
    url: '/account',
    views: {
      'tab-account': {
        templateUrl: 'templates/tab-account.html',
        controller: 'AccountCtrl'
      }
    }
  });

  $urlRouterProvider.otherwise('/tab/dash');

}

});

【问题讨论】:

  • 好吧,你没有显示任何 HTML,所以没有太多信息可以继续,但我想当没有 @987654323 时很难转到 /tab/dash @为此....

标签: javascript angularjs cordova ionic-framework javascriptcore


【解决方案1】:

问题是$urlRouterProvider.otherwise('/tab/dash');

你的 tab.dash 状态在哪里。

也许你的意思是 /tab/account url

  $urlRouterProvider.otherwise('/tab/account');

【讨论】:

  • 我试图删除一些状态以保持代码更短。 html中没有错误,因为我在没有工厂的情况下对其进行了测试,并且可以正常工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-14
  • 2011-03-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多