我從來沒有遇到過這個問題,我知道這是一個小問題......但我似乎無法弄清楚什麼是錯誤的......我的部分1沒有正確加載,而是它擊中否則路線回到我的/登錄(我分配)。 每當我點擊創建一個調查鏈接,它會將我重定向回登錄名,並且URL顯示這個http://localhost:3000/#!/login#%2Fcreate,但是當我將http://localhost:3000/#!/create放入其工作的URL中時。不太清楚問題是什麼。請幫忙!角度部分不工作
var app = angular.module('myApp', ['ngRoute']);
app.config(function($routeProvider){
\t $routeProvider
\t .when('/login', {
\t \t templateUrl: 'partials/login.html',
\t \t controller: 'UserController'
\t })
\t .when('/dashboard', {
\t \t templateUrl: 'partials/dashboard.html',
\t \t controller: 'SurveyController'
\t })
\t .when('/create', {
\t \t templateUrl: 'partials/create.html',
\t \t controller: 'SurveyController'
\t })
\t .when('/poll/:id', {
\t \t templateUrl: 'partials/poll.html'
\t })
\t .otherwise({
\t \t redirectTo: '/login'
\t });
})
<!DOCTYPE html>
<html>
<head>
\t <title>Survey Polls</title>
\t <!-- CSS -->
\t <link rel="stylesheet" href="bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="styles.css"> \t
\t <!-- Angular -->
\t <script src="angular/angular.js"></script>
\t <script src="angular-route/angular-route.js"></script>
\t <!-- jQuery/Bootstrap -->
\t <script src="jquery/dist/jquery.js"></script>
\t <script src="bootstrap/dist/js/bootstrap.js"></script>
\t <!-- App.js -->
\t <script src="app.js"></script>
\t <!-- Controllers/Factories -->
\t <script src="controllers/SurveyController.js"></script> \t
\t <script src="controllers/UserController.js"></script>
\t <script src="factories/SurveyFactory.js"></script>
\t <script src="factories/UserFactory.js"></script>
</head>
<body ng-app="myApp">
\t <div class="container">
\t \t <div ng-view></div>
\t </div>
</body>
</html>
<a href="#/create">Create a new survey</a>
<h3>Current polls:</h3>
<table border="1">
\t <thead>
\t \t <tr>
\t \t \t <th>Name</th>
\t \t \t <th>Survey Question</th>
\t \t \t <th>Date Posted</th>
\t \t \t <th>Action</th>
\t \t </tr>
\t </thead>
\t <tbody>
\t \t <tr ng-repeat="s in surveys">
\t \t \t <td>{{ s._user.username }}</td>
\t \t \t <td>{{ s.question }}</td>
\t \t \t <td>{{ s.created_at }}</td>
\t \t \t <td><button ng-show="loggedInUser._id == s._user._id" ng-click="delete(s._id)">Delete</button></td>
\t \t </tr>
\t </tbody>
</table>
哪一個不工作創建? – Yaser
是的,對不起,我編輯了我的帖子。哎呦! –
向我們展示瞭如何導航以創建狀態...觸發它的功能。 – Thalaivar