ngRoute似乎不工作 [英] ngRoute doesn't seem to work
问题描述
我有一个web应用程序似乎并不在所有的工作,如果我尝试使用ngRoute转产主要页面视图。路由的配置如下:
I have a web app that doesn't seem to work at all if I try to use ngRoute approach to changing primary page view. The routing config looks like:
var app;
app = angular.module('genehaxx', ['ngGrid','ngRoute', 'ngSanitize', 'ui.bootstrap','genehaxx.filters', 'genehaxx.services'])
.config(function($routeProvider){
//route setup
$routeProvider
.when('/workflows', {
templateURL: '/partials/workspace_view.html',
controller: 'MainController'
})
.when('/jobs', {
templateURL: '/partials/submissions_view.html' ,
controller: 'MainController'
})
.when('/', {
templateURL: '/partials/analyses_view.html',
controller: 'MainController'
})
.when('/analyses', {
redirectTo: '/'
})
.otherwise({
redirectTo: '/'
});
});
function MainController($scope, $modal, $rootScope, User, Data, Workflow, Step){
//lots of proprietary code here..
}
我已经有和没有'/'的谐音前尝试过。我曾与在其目录中的HTTP服务器下的nginx并直接代理其正常的Web服务器的反向试了一下两者。在这两种情况下,没有任何的谐音页曾经从服务器请求的证据。其主要观点是有点毛毛在全部发布,但相关的位如下:
I have tried it with and without the '/' in front of partials. I have tried it both with its normal web-server reverse proxied under nginx and directly under http-server from its directory. In both cases there is no evidence whatsoever that the partials pages are ever requested from the server. The main view is a bit hairy to post in entirety but the relevant bits look like:
<!doctype html>
<html lang="en" ng-app="genehaxx" >
<head>
<meta charset="utf-8">
<title>Welcome to Genengine!</title>
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="css/app.css"/>
<link rel="stylesheet" href="css/ng-grid.css">
<script src="lib/jquery-2.0.2.js"></script>
<script src="libs/angular/angular.js"></script>
<script src="libs/angular-route/angular-route.min.js"></script>
<script src="libs/angular-sanitize/angular-sanitize.js"></script>
<script src="lib/transition.js"></script>
<script src="lib/bootstrap-custom/ui-bootstrap-custom-tpls-0.10.0.js"></script>
<script src="lib/ng-grid-2.0.7.debug.js"></script>
<script src="js/app.js"></script>
<script src="js/filters.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore.js"></script>
<script src="js/objects.js"></script>
<script src="js/services2.js"></script>
<script src="js/dropdownToggle.js"></script>
</head>
<body>
<div id="main">
<div ng-view></div>
</div>
</body>
</html>
,因为它似乎无关紧要,我得到同样的结果中点击或用#whatever直接输入网址我已经离开了导航栏的东西。在/库目录有最新的角,角路线,从凉亭angulare-sanitize方法。
I have left off the navbar stuff as it seems irrelevant and I get the same results clicking it or directly entering the url with #whatever. The /libs directories have the latest angular, angular-route, angulare-sanitize from bower.
小样本我想在我的图书馆和谐音堵漏似乎工作这更加令人沮丧。我一直难倒在这几天。我砍死它周围的生产与NG-包括一些聪明code的一塌糊涂,但我宁愿得到这个工作。什么蹦出来?当我说这是行不通的,再我的意思是,我看到没有证据表明发生在任何路由,这些谐音永远不会从服务器请求。
Small samples I tried plugging in my libraries and partials seem to work which is even more frustrating. I have been stumped on this for days. I hacked around it in production with mess of ng-includes and some "clever" code but I would rather get this working. Anything pop out? When I say it doesn't work, again I mean that I see no evidence that any routing occurred in that these partials are never requested from the server.
推荐答案
您里面有错别字你的在
调用:
You have typos inside of your when
calls:
例如:
templateURL: '/partials/workspace_view.html',
应
templateUrl: '/partials/workspace_view.html',
(注意在帽上的差异,templateURL变为templateUrl)
(notice the difference in caps, templateURL changes to templateUrl)
这篇关于ngRoute似乎不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!