2017-01-16 98 views
0

我有一個路由angularjs的問題。當打開瀏覽器看網頁看不到的觀點,在我有這個消息enter image description here

controller.js控制檯

angular.module('contactMgr',['ngRoute']) 
.controller('AppCtrl',function ($scope,$http){ 
    // Controller for index.html 
} 
.config(function($routeProvider){ 
    $routeProvider.when('/',{ 
          controller: 'indexCtrl', 
          templateUrl: 'assets/partials/index.html' 
         }) 
       .when('/add-contact',{ 
          controller: 'addCtrl', 
          templateUrl: 'assets/partials/add.html' 
         }); 
    }) 
.controller('indexCtrl',function($scope){ 
}) 

.controller('addCtrl',function($scope){ 
}); 

index.html的(不是資產/諧音/ index.html的)

<div class="container"> 
    <ng-view></ng-view> 
</div> 

我用:

jQuery的3.1.1.min.js

angul ar.min.js v1.2.32

角route.min.js

謝謝!

我解決了這個問題!

我導入min.js,我改變angular.min.js和angular-route.min.js與angular.js和angular-route.js和工作正常,但我不明白爲什麼...在我讀的一個網站,因爲是分鐘文件,但我不明白如何使用最小文件。

+0

你在項目中包含的所有資源,你的腳本文件(角等)? – lealceldeiro

+0

是的!我都在我的項目文件夾 –

+0

我不明白,因爲我已經完成了許多項目與縮小的文件,它完美的作品。 – lealceldeiro

回答

0

您還沒有關閉該路由配置,

var app = angular.module("contactMgr", ['ngRoute']); 
app.config(['$routeProvider', function($routeProvider) { 
    $routeProvider. 
    when('/', { 
    templateUrl: 'main.html', 
    controller: 'indexCtrl', 
    controllerAs: 'homeCtrl' 
    }). 
    when('/contact', { 
    templateUrl: 'contact.html', 
    controller: 'addCtrl', 
    controllerAs: '' 
    }) 

    .otherwise({ 
    redirectTo: '/' 
    }); 

}]) 
app.controller('indexCtrl', function($scope) { 

}); 
app.controller('addCtrl', function($scope) { 

}); 

DEMO

+0

不,如果不聲明var應用程序,工作正常。問題是在導入角e路徑,我導入min,但我必須導入未壓縮的文件。但我不明白爲什麼... –

+0

標記爲答案,如果它有幫助 – Sajeetharan

相關問題