2017-04-27 60 views
1

工作我有以下代码NG-路线不与其他模块

var balaitus = angular.module("balaitus", ["ngRoute"]); 

// configure our routes 
balaitus.config(function($routeProvider) { 
    $routeProvider 
    // route for the home page 
     .when('/', { 
      templateUrl : 'home_usuario2.html', 
      controller : 'usuarioCtrl' 
     }) 

     .when('/home_usuario', { 
      templateUrl : 'home_usuario2.html', 
      controller : 'usuarioCtrl' 
     }) 

     // route for the about page 
     .when('/estadisticas', { 
      templateUrl : 'estadisticas.html', 
      controller : 'estadisticasCtrl' 
     }) 

     // route for the contact page 
     .when('/hashtags', { 
      templateUrl : 'hashtags.html', 
      controller : 'hashtagsCtrl' 
     }) 
     .otherwise({ 
      templateUrl : 'home_usuario2.html', 
      controller : 'usuarioCtrl' 
    }); 
}); 

// create the controller and inject Angular's $scope 
balaitus.controller('usuarioCtrl', function($scope) { 
    // create a message to display in our view 
    $scope.message = 'Hi! This is the home page.'; 
}); 

balaitus.controller('estadisticasCtrl', function($scope) { 
    $scope.message = 'Hi! This is the estadisticas page.'; 
}); 

balaitus.controller('hashtagsCtrl', function($scope) { 
    $scope.message = 'Would you like to contact us?'; 
}); 

的代码简单地路由不同的页面,并设置相应的控制器。它工作正常,但是当我在[]之间添加另一个角度模块时,例如ngFileUpload或ui.bootstrap.demo,ng-route不起作用,但是为什么?

回答

1

你应该增加它在构造函数中,如:

var balaitus=angular.module("balaitus", ['webix', 'ngRoute','ui.router']); 



balaitus.config(['$stateProvider', '$urlRouterProvider', '$routeProvider', '$locationProvider', '$qProvider', function ($stateProvider, $urlRouterProvider, $routeProvider, $locationProvider, $qProvider) { 
$routeProvider .... 

当然,包括在乌拉圭回合的HTML代码中的js文件

<script src="Scripts/angular-route.js"></script>