[英]AngularJS Module 'ui.router' is not available for my Djangular project
Django is a python web frameworks, AngularUI Router is an AngularJS module for heroic routing. Django是一个python web框架,AngularUI Router是一个用于英雄路由的AngularJS模块。 Together they fight crime.
他们一起打击犯罪。
Or they would if it could find the 'ui.router' module. 或者他们会找到'ui.router'模块。
Here're my imports: 这是我的进口:
<script src="{% static 'angular.js' %}"></script>
<script src="{% static 'angular-route.js' %}"/>
<script src="{% static 'angular-ui-router.js' %}"></script>
<script src="{% static 'angular-cookies.js' %}"></script>
<script src="{% static '/djangular/app.js' %}"></script>
<script src="{% static 'js/app.js' %}"></script>
<script src="{% static 'js/services.js' %}"></script>
<script src="{% static 'js/controllers.js' %}"></script>
<script src="{% static 'js/filters.js' %}"></script>
<script src="{% static 'js/directives.js' %}"></script>
Here the {% static 'path/to/script' %}
notation searches a list of paths for my static file. 这里
{% static 'path/to/script' %}
表示法搜索我的静态文件的路径列表。
Here they are: 他们来了:
D:\Django_Projects\nwod_characters\static
D:\Django_Projects\nwod_characters\static\css
D:\Django_Projects\nwod_characters\static\fonts
D:\Django_Projects\nwod_characters\static\img
D:\Django_Projects\nwod_characters\static\js
D:\Django_Projects\nwod_characters\static\js\app # angular-ui-router.js lives here
D:\Django_Projects\nwod_characters\static\svg
D:\Django_Projects\nwod_characters\characters\app
D:\Django_Projects\nwod_characters\characters\app\css
D:\Django_Projects\nwod_characters\characters\app\js
D:\Django_Projects\nwod_characters\characters\app\partials
And proof angular-ui-router
exists, from Sublime: 并且证明
angular-ui-router
存在,来自Sublime:
And here's a snippet from my app.js 这是我的app.js的一个片段
angular.module('characters', ['djangular','ui.router',
'characters.filters', 'characters.services', 'characters.directives', 'characters.controllers'])
.config(['$stateProvider','DjangoProperties',
function($stateProvider, DjangoProperties, $urlRouterProvider) {
$urlRouterProvider.otherwise("/users");
// Now set up the states
$stateProvider
.state('users', {
url: "/users",
templateUrl: "partials/users.html"
})
I've tried to set up this file correctly, but I'm not 100% sure. 我试图正确设置这个文件,但我不是百分百肯定。 JavaScript is not my native language!
JavaScript不是我的母语! In my understanding, the file
angular-ui-router.js
exports the module ui.router
, that has the providers '$stateProvider'
and $urlRouterProvider
. 根据我的理解, 文件
angular-ui-router.js
导出模块 ui.router
,它具有提供者 '$stateProvider'
和$urlRouterProvider
。 Is that right? 那正确吗? If so what am I doing wrong?
如果是这样,我做错了什么?
I've also looked at the plunkr provided by AngularUI Routing. 我也看了看plunkr由AngularUI路由提供。 They configure their app slightly different, but I think the result should be the same:
他们配置他们的应用略有不同,但我认为结果应该是相同的:
<script src="//angular-ui.github.io/ui-router/release/angular-ui-router.js"></script>
....
var myapp = angular.module('myapp', ["ui.router"])
myapp.config(function($stateProvider, $urlRouterProvider){
So where am I going wrong that angular can't load the ui-router
module? 那么我哪里错了,角度无法加载
ui-router
模块?
The problem is here: 问题出在这里:
<script src="{% static 'angular-route.js' %}"/>
<script src="{% static 'angular-ui-router.js' %}"></script>
The first line is an attempt at a self closing script tag. 第一行是尝试自闭脚本标记。 This doesn't work .
这不起作用 。
There is an error in the parameters for your config definition, you have forgotten to add '$urlRouterProvider' to list of parameters in the list. 您的配置定义的参数出错,您忘记将“$ urlRouterProvider”添加到列表中的参数列表中。
angular.module('characters', ['djangular','ui.router',
'characters.filters', 'characters.services', 'characters.directives', 'characters.controllers'])
.config(['$stateProvider','DjangoProperties', '$urlRouterProvider',
function($stateProvider, DjangoProperties, $urlRouterProvider) {
$urlRouterProvider.otherwise("/users");
// Now set up the states
$stateProvider
.state('users', {
url: "/users",
templateUrl: "partials/users.html"
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.