角路線不是爲我工作..角路線不工作
我的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 .. 請幫助!
你讓你的終端上的任何錯誤? –
你有ng-view嗎? –
@ShamalPerera。我贊同你。 := 1 –