2015-09-28 125 views
1

角路線不是爲我工作..角路線不工作

我的JS:

'use strict'; 

// Declare app level module which depends on filters, and services 
var chatApp = angular.module('myApp', ['ngRoute']); 

// configure our routes 
chatApp.config(function($routeProvider) { 
    $routeProvider 

     // route for the home page 
     .when('/index', { 
      templateUrl : 'index.html', 
      controller : 'mainCtrl' 
     }) 

     // route for the about page 
     .when('/chat', { 
      templateUrl : 'views/chat.html', 
      controller : 'chatCtrl' 
     }) 
     .otherwise({redirectTo: '/index'}); 
}); 

chatApp.controller('mainCtrl', function($scope) { 
    // create a message to display in our view 
    $scope.message = 'Everyone come and see how good I look!'; 
}); 

chatApp.controller('chatCtrl', function($scope) { 
    // create a message to display in our view 
    $scope.message = 'Everyone come and see how good I look!'; 
}); 

在HTML:

<html ng-app="myApp"> 

加我的腳本也。

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular.min.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular-resource.min.js"> 
</script> 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular-route.min.js"> 
</script> 
<script src="https://cdn.firebase.com/js/client/2.0.4/firebase.js"></script> 
<script src="https://cdn.firebase.com/libs/angularfire/0.9.0/angularfire.min.js"></script> 
<script src="scripts/app.js"></script> 


URL : ...goaway-web/app/chat Example what I am trying. 
goaway-web/app/index 

雖然重定向或直接輸入不正常的URL .. 請幫助!

+0

你讓你的終端上的任何錯誤? –

+3

你有ng-view嗎? –

+0

@ShamalPerera。我贊同你。 := 1 –

回答

2

試一下#。

樣品: <a href="#/index">SOME_DETAIL</a>

並請,你有沒有實現對ng-viewindex.html

+0

我試過它不適用於此。 –

+0

我們可以用代碼看到你的錨標籤href嗎?並告訴我們您的應用正確的路徑。 (你通過'view'選擇的)? –