获得"未捕获的错误:"在我的水疗应用程序

时间:2018-06-12 06:02:59

标签: angularjs

的index.html:

<!DOCTYPE html>
<html ng-app="Dapp">
<head>
<meta charset="ISO-8859-1">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-route.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular-resource.min.js"></script>
<title>..::D_App:..</title>
</head>
<body ng-controller="LoginControl">
 <div id="ngView" ng-view style="padding: 0px;"></div>
<script type="text/javascript" src="Controllers/Controller.js"></script>
<script type="text/javascript" src="Controllers/LoginControl.js"></script>
</body>
</html>

Controller.js:

var app=angular.module('Dapp',['ngRoute']);
app.config(function($routeProvider) {
$rootProvider
.when("/", {templateUrl : "Pages/login.html",controller : "LoginControl"})
.when("/login", {templateUrl : "Pages/login.html" , controller:"LoginControl"})
});

LoginControl.js:

app.controller('LoginControl',function($scope){
    alert("HELLO");
});

1 个答案:

答案 0 :(得分:0)

您的 Controller.js

中的代码中有拼写错误
var app=angular.module('Dapp',['ngRoute']);
app.config(function($routeProvider) {
$rootProvider
.when("/", {templateUrl : "Pages/login.html",controller : "LoginControl"})
.when("/login", {templateUrl : "Pages/login.html" , controller:"LoginControl"})
});

$ rootProvider 更改为 $ routeProvider ,它应该可以正常工作