<!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>
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"})
});
app.controller('LoginControl',function($scope){
alert("HELLO");
});
答案 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 ,它应该可以正常工作