2017-04-27 81 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>