第一次将 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)
如您所见,它更新了我的文件中的内容,因为它只是新的应用程序。
索引.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>
应用程序.js
var app = angular.module('app', ['Controllers', 'Directives', 'Services']);
控制器.js
angular.module('Controllers', []);
指令.js
angular.module('Directives', []);
服务.js
angular.module('Services', []);