简体   繁体   English

使用RouteProvider加载AngularJs时出错

[英]Error in loading AngularJs with RouteProvider

I am new to angularJs, while using routeProvider angularJs through following error. 我是angularJs的新手,同时通过以下错误使用routeProvider angularJs。 I tried everything but I did not found an solution. 我尝试了一切,但没有找到解决方案。

Errors: 错误:

Error: Argument 'fn' is not a function, got string from viewApp
TypeError: angular.$$minErr is not a function

Here is my html file 这是我的html文件

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="angular.min.js" language="javascript" type="application/javascript"></script>
<script src="angular-route.js"></script>
<script src="custom.js"></script>
<title>Anguler App</title>
</head>
<body ng-app="viewApp">
<a href="#/click">Home</a>
    <div ng-view>

    </div>
</body>
</html>

AngularJs code that I am using. 我正在使用的AngularJs代码。

var myapp=angular.module('viewApp',[]);
myapp.config(['$routeProvider',function($routeProvider){
        $routeProvider.when("/click",{
            templateUrl:"partialview.html"
            }).otherwise({
        redirectTo: '/'
      });
    }]);

You've linked the angular-route.js but not using it in your app. 您已链接angular-route.js,但未在应用程序中使用它。 Do a dependency injection - 做依赖注入-

var myapp=angular.module('viewApp',['ngRoute']);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM