我到处寻找这个问题的答案,但是这个问题的每一个例子似乎都是非常独特的。也许几只额外的眼睛可以帮助我们了解到这一点。
我在我的控制台上收到一个错误:
app.js:23 Uncaught :角未定义
我的角度应用程序工作得很好,但是这个错误继续存在,尽管我所做的。我认为这个错误是当我重组代码以遵循托德格言所写的风格指南时出现的。无论如何,我的app.js如下:
(function() {
function config($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'partial/main'
})
.when('/assignment/:id', {
templateUrl: 'partial/assignment',
controller: 'SubmissionController'
}).otherwise({
redirectTo: '/'
});
}
angular
.module('myApp', ['ngRoute', 'ui.materialize', 'ngAnimate'])
.config(config);
})();我的依赖关系如下:
doctype html
html(ng-app="myApp")
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible", content="IE=edge")
meta(name="viewport", content="width=device-width, initial-scale=1.0, maximum-scale=1.0")
title= title
link(rel='icon', type='image/png', href='favicon.ico')
// bower:css
link(rel='stylesheet', href='../bower_components/animate.css/animate.css')
// endbower
script(src='js/app.js') styles
link(rel="stylesheet", href="css/app.css")
link(href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet")
body(ng-controller="AssignmentController")
block content
//- lib js
// bower:js
script(src='../bower_components/jquery/dist/jquery.js')
script(src='../bower_components/angular/angular.js')
script(src='../bower_components/Materialize/bin/materialize.js')
script(src='../bower_components/angular-route/angular-route.js')
script(src='../bower_components/angular-animate/angular-animate.js')
script(src='../bower_components/angular-materialize/src/angular-materialize.js')
// endbower
//- app js
script(src='js/app.js')
script(src='js/controllers.js')
script(src='js/services.js')
script(src='js/directives.js')
script(src='//localhost:35729/livereload.js') 经过反复的尝试,我忽略了每一个依赖项。我尝试重新安排每个依赖项的加载顺序,甚至尝试重新排列每个应用程序特定文件的列表顺序,但都没有效果。
对此有什么想法吗?
发布于 2016-11-04 20:59:25
感谢@JJJ
“那么,您正在加载两次app.js :一次是在加载角之前在头部加载,另一次是在角度加载后加载到体内。第一个脚本抛出一个错误,但该应用程序工作正常,因为它在第二次加载时运行时没有错误:”
doctype html
html(ng-app="myApp")
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible", content="IE=edge")
meta(name="viewport", content="width=device-width, initial-scale=1.0, maximum-scale=1.0")
title= title
link(rel='icon', type='image/png', href='favicon.ico')
// bower:css
link(rel='stylesheet', href='../bower_components/animate.css/animate.css')
// endbower
// - [FIX] removed: script(src='js/app.js')
link(rel="stylesheet", href="css/app.css")
link(href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet")
body(ng-controller="AssignmentController")
block content
//- lib js
// bower:js
script(src='../bower_components/jquery/dist/jquery.js')
script(src='../bower_components/angular/angular.js')
script(src='../bower_components/Materialize/bin/materialize.js')
script(src='../bower_components/angular-route/angular-route.js')
script(src='../bower_components/angular-animate/angular-animate.js')
script(src='../bower_components/angular-materialize/src/angular-materialize.js')
// endbower
//- app js
script(src='js/app.js')
script(src='js/controllers.js')
script(src='js/services.js')
script(src='js/directives.js')
script(src='//localhost:35729/livereload.js') https://stackoverflow.com/questions/36240841
复制相似问题