Routeprovider无法在角度js中工作 [英] Routeprovider is not working in angular js
本文介绍了Routeprovider无法在角度js中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<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>
var module = angular.module("MyModule", ["ngRoute"]);
module.config(function ($routeProvider) {
$routeProvider
.when("/login", {
templateUrl: "login.html",
controller: "loginController"
})
.when("/user", {
templateUrl: "user.html",
controller: "userController"
})
.when("/", {
templateUrl: "main.html"
})
});
module.controller("loginController", function ($scope) {
$scope.message = "Login Test";
});
module.controller("userController", function ($scope) {
$scope.message = "User Test";
});
</script>
</head>
<body ng-app="MyModule">
<a href="#!/login">Login</a>
<a href="#!/user">User</a>
<div ng-view></div>
</body>
</html>
Login.html : {{ message }}
我的尝试:
谁能告诉我哪里有错误请....这段代码在我的chrome中不起作用。请帮助我....
What I have tried:
Can anyone tell me where is error please....This code is not working in my chrome.Please help me....
推荐答案
routeProvider){
routeProvider) {
routeProvider
.when(/ login,{
templateUrl:login。 html,
控制器:loginController
})
.when(/ user,{
templateUrl:user.html,
controller: userController
})
.when(/,{
templateUrl:main.html
})
});
module.controller(loginController,function(
routeProvider .when("/login", { templateUrl: "login.html", controller: "loginController" }) .when("/user", { templateUrl: "user.html", controller: "userController" }) .when("/", { templateUrl: "main.html" }) }); module.controller("loginController", function (
scope){
这篇关于Routeprovider无法在角度js中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文