【发布时间】:2014-01-30 21:41:05
【问题描述】:
第一次将 ng-view 与 Angular 一起使用,并且在 Angular js 与 ng-view 的新应用中,我遇到了所有这些 scrollTo 错误。我怎样才能解决这个问题?我检查了 StackOverflow 和 Google,但找不到解决方案。即使是 Angular 种子应用程序我也遇到了同样的问题。
控制台错误
TypeError: Property 'scrollTo' of object [object global] is not a function
at scroll (http://localhost/angular/lib/angular.js:2946:26)
at Object.Scope.$eval (http://localhost/angular/lib/angular.js:8685:28)
at Object.Scope.$digest (http://localhost/angular/lib/angular.js:8548:23)
at Object.Scope.$apply (http://localhost/angular/lib/angular.js:8771:24)
at http://localhost/angular/lib/angular.js:986:15
at Object.invoke (http://localhost/angular/lib/angular.js:2873:25)
at resumeBootstrapInternal (http://localhost/angular/lib/angular.js:984:14)
at bootstrap (http://localhost/angular/lib/angular.js:998:12)
at angularInit (http://localhost/angular/lib/angular.js:959:5)
at http://localhost/angular/lib/angular.js:16310:5 angular.js:6173
TypeError: Property 'scrollTo' of object [object global] is not a function
at scroll (http://localhost/angular/lib/angular.js:2946:26)
at <error: illegal access>
at Object.Scope.$broadcast (http://localhost/angular/lib/angular.js:8935:28)
at http://localhost/angular/lib/angular.js:7960:26
at wrappedCallback (http://localhost/angular/lib/angular.js:7303:59)
at wrappedCallback (http://localhost/angular/lib/angular.js:7303:59)
at http://localhost/angular/lib/angular.js:7340:26
at Object.Scope.$eval (http://localhost/angular/lib/angular.js:8685:28)
at Object.Scope.$digest (http://localhost/angular/lib/angular.js:8548:23)
at Object.Scope.$apply (http://localhost/angular/lib/angular.js:8771:24)
更新了我的文件中的内容,正如您所见,它只是全新的应用程序。
index.html
<!doctype html>
<html lang="en" ng-app="app">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<title>Mobile App</title>
<link href="css/default.css" rel="stylesheet" type="text/css">
<link href="css/bootstrap-min.css" rel="stylesheet" type="text/css">
</head>
<body>
<div ng-view></div>
<!--<script src="lib/angular-min.js"></script>-->
<script src="lib/angular.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/directives.js"></script>
<script src="js/services.js"></script>
</body>
</html>
app.js
var app = angular.module('app', ['Controllers', 'Directives', 'Services']);
controllers.js
angular.module('Controllers', []);
directives.js
angular.module('Directives', []);
services.js
angular.module('Services', []);
【问题讨论】:
-
请提供引发此错误的代码!
-
编辑了问题。没有特定的代码,它只是一个新的应用程序和引导程序。如果我使用 ng-view,我只会遇到这些错误。
标签: angularjs