如何解决错误:路由到页面

时间:2015-10-23 12:53:33

标签: javascript jquery angularjs

error image link 我在firebug中得到这个错误。 这是我的代码,我使用的是角度版本1.4.7和jquery版本1.11.3

var app = angular.module('myapp', ['ngRoute']);

app.config(['$routeProvider', '$locationProvider',
  function($routeProvider, $locationProvider) {
    $routeProvider.
    when('/', {
      title: 'dashboard',
      templateUrl: 'home.htm',
      caseInsensitiveMatch: true,
      controller: function($scope, $http, $timeout, $rootScope) {
        $scope.controllerName = "HomeController";




        $http({
            method: "GET",
            //url: "User/NewsData.php",
            params: {
              //page: "Get"
            }
          })
          .success(function(data) {
            //$scope.News = data;

          });


        //jQuery(window).trigger("resize");

      }
    }).


    when('/Grocery', {
      title: 'Grocery',
      templateUrl: 'layout.htm',

      caseInsensitiveMatch: true,

      controller: function($scope, $http, $routeParams, $route, $location) {
        $scope.controllerName = "Home1Controller";

        $scope.Goto = function(tbname, category, subcategory) {


          var request = $http({
            method: "GET",
            url: "getdata.php",
            params: {
              Page: "ProductData",
              Tablename: tbname,
              Category: category,
              Subcategory: subcategory
            },
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded'
            }
          });
          request.success(function(data) {
            $scope.products = data.products;

          });
        }

      }
    }).
    when('/Beverages', {
      title: 'Beverages',
      templateUrl: 'beverages.htm',

      caseInsensitiveMatch: true,

      controller: function($scope, $http, $routeParams, $location) {
        $scope.controllerName = "Home1Controller";

        $scope.Goto = function(tbname, category, subcategory) {


          var request = $http({
            method: "post",
            url: "getdata.php",
            data: {
              Page: "ProductData",
              ProductName: tbname,
              Category: category,
              Subcategory: subcategory
            },
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded'
            }
          });
          request.success(function(data) {
            $scope.products = response.products;

          });
        }

      }
    }).

    when('/Households', {
      title: 'Households',
      templateUrl: 'households.htm',

      caseInsensitiveMatch: true,

      controller: function($scope, $http, $routeParams, $location) {
        $scope.controllerName = "Home1Controller";

        $scope.Goto = function(tbname, category, subcategory) {


          var request = $http({
            method: "post",
            url: "getdata.php",
            data: {
              Page: "ProductData",
              ProductName: tbname,
              Category: category,
              Subcategory: subcategory
            },
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded'
            }
          });
          request.success(function(data) {
            $scope.products = response.products;

          });
        }

      }
    }).

    when('/BrandedFood', {
      title: 'BrandedFood',
      templateUrl: 'brandedfoods.htm',

      caseInsensitiveMatch: true,

      controller: function($scope, $http, $routeParams, $location) {
        $scope.controllerName = "Home1Controller";

        $scope.Goto = function(tbname, category, subcategory) {


          var request = $http({
            method: "post",
            url: "getdata.php",
            data: {
              Page: "ProductData",
              ProductName: tbname,
              Category: category,
              Subcategory: subcategory
            },
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded'
            }
          });
          request.success(function(data) {
            $scope.products = response.products;

          });
        }

      }
    }).

    when('/PersonalCare', {
      title: 'PersonalCare',
      templateUrl: 'personalcare.htm',

      caseInsensitiveMatch: true,

      controller: function($scope, $http, $routeParams, $location) {
        $scope.controllerName = "Home1Controller";



      }
    }).
    otherwise({
      redirectTo: '/'
    });
    $locationProvider.html5Mode({
      enabled: true,
      requireBase: false
    });
  }
]);

app.controller('MainCrtl', function($scope, $route, $http, $timeout, $location, $rootScope) {
  $scope.init = function(tbname, category, Type) {
    var request = $http({
      method: "POST",
      url: "navigationData.php",
      data: {
        Page: "TabData",
        Tablename: tbname,
        Category: category,
        Typedata: Type
      },
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }

    });
    request.success(function(data) {
      $scope.tabdata = data.Details;

    });
  }
});

app.controller('sliderCtrl', function($scope, $http, $timeout, $location, $rootScope) {
  $http.get("slideData.php")
    .success(function(response) {
      $scope.names = response.image_link;
    });
});

app.controller('tabCtrl', function($scope, $http, $routeParams, $location, $rootScope) {
  $scope.init = function(tbname, category, Type) {
    var request = $http({
      method: "POST",
      url: "navigationData.php",
      data: {
        Page: "TabData",
        Tablename: tbname,
        Category: category,
        Typedata: Type
      },

    });
    request.success(function(data) {
      $scope.tabdata = data.Details;

    });
  }
});

我有ng-href在html中使用ng-click in anchor tag点击它显示html但是我得到了上面的错误。 layout.htm是html页面,其中没有显示从php获取的数据。

错误: - 这是我在萤火虫中犯的错误....

错误:未定义视图 @http:'// www.domain.com/Angular/assets/lib/jquery/jquery-1.11.3.js'line 339> EVAL:3:1 jQuery.Callbacks/fire@http:'// www.domain.com/Angular/assets/lib/jquery/jquery-1.11.3.js'line 339> EVAL:3148:10 jQuery.Callbacks/self.add@http'://www.domain.com/Angular/assets/lib/jquery/jquery-1.11.3.js'line 339> EVAL:3194:7 jQuery.fn.ready@http'://www.domain.com/Angular/assets/lib/jquery/jquery-1.11.3.js line 339'> EVAL:3428:2 @http'://www.domain.com/Angular/assets/lib/jquery/jquery-1.11.3.js'line 339> EVAL:2:1 .globalEval /< @http '://www.domain.com/Angular/assets/lib/jquery/jquery-1.11.3.js':339:5 .globalEval @ HTTP '://www.domain.com/Angular/assets/lib/jquery/jquery-1.11.3.js':338:1 .domManip @ HTTP '://www.domain.com/Angular/assets/lib/jquery/jquery-1.11.3.js':5985:1 .append @ HTTP '://www.domain.com/Angular/assets/lib/jquery/jquery-1.11.3.js':5758:1 html的/< @http '://www.domain.com/Angular/assets/lib/jquery/jquery-1.11.3.js':5884:5 jQuery.access@http'://www.domain.com/Angular/assets/lib/jquery/jquery-1.11.3.js:4157:5 html的@ HTTP '://www.domain.com/Angular/assets/lib/jquery/jquery-1.11.3.js':5848:1 ngViewFillContentFactory /<。链接@ HTTP '://www.domain.com/Angular/assets/js/angular-route.js':971:7 invokeLinkFn @ HTTP '://www.domain.com/Angular/assets/js/angular.1.4.7.js':8789:9 nodeLinkFn @ HTTP '://www.domain.com/Angular/assets/js/angular.1.4.7.js':8289:1 compositeLinkFn @ HTTP '://www.domain.com/Angular/assets/js/angular.1.4.7.js':7680:13 publicLinkFn @ HTTP '://www.domain.com/Angular/assets/js/angular.1.4.7.js':7555:30 createBoundTranscludeFn / boundTranscludeFn @ HTTP '://www.domain.com/Angular/assets/js/angular.1.4.7.js':7699:1 controllersBoundTransclude @ HTTP '://www.domain.com/Angular/assets/js/angular.1.4.7.js':8316:18 更新@ HTTP '://www.domain.com/Angular/assets/js/angular-route.js':935:25 $ RootScopeProvider /这$ gethttp://www.domain.com/Angular/assets/js/angular.1.4.7.js':16311:15 commitRoute /< @http '://www.domain.com/Angular/assets/js/angular-route.js':619:15 processQueue @ HTTP '://www.domain.com/Angular/assets/js/angular.1.4.7.js':14745:28 scheduleProcessQueue /< @http '://www.domain.com/Angular/assets/js/angular.1.4.7.js':14761:27 $ RootScopeProvider /这$。得到“

1 个答案:

答案 0 :(得分:1)

我找到了!视图未定义。 Here!