我的角度js路由不起作用。 [英] My angular js routing is not working.

查看:83
本文介绍了我的角度js路由不起作用。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Angular js路由无法正常工作。



请在我试过的部分和帮助中找到以下代码。



我尝试过:



我的index.html如下。



Angular js routing not working.

please find code below in what i hv tried section and help.

What I have tried:

My index.html below.

<!doctype html>       
<table style="font-family: Arial"><tbody><tr><td colspan="2" class="header">
	<h1>
		My Blog
	</h1>
	</td></tr><tr><td class="leftMenu">
		<a href="#/home">Home</a>
		<a href="#/courses">Courses</a>
		<a href="#/students">Students</a>
	</td><td class="mainContent">
		<ng-view>
	</td></tr><tr><td colspan="2" class="footer">
		Website Footer
	</td></tr></tbody></table>



-------------------------------- -------------------------


---------------------------------------------------------

var app = angular .module("Demo", ["ngRoute"])
.config(function ($routeProvider) {
$routeProvider 
.when("/home", {
	template : "Templates/home.html",
	controller: "homeController"
	})
	.when("/courses", {
		templateUrl: "Templates/courses.html",
		controller: "coursesController"
	})
});
app.controller("homeController", function($scope) {
   $scope.message="Welcome Sunny";
});
app.controller("coursesController", function ($scope) {
$scope.courses = ["C#", "VB.NET", "ASP.NET", "SQL Server"];
});

推荐答案

routeProvider){
routeProvider) {


routeProvider
何时 / home,{
模板: Templates / home.html
controller: homeController
})
何时 / courses,{
templateUrl: Templates / courses.html
controller: coursesController
})
});
app.controller( homeController,功能(
routeProvider .when("/home", { template : "Templates/home.html", controller: "homeController" }) .when("/courses", { templateUrl: "Templates/courses.html", controller: "coursesController" }) }); app.controller("homeController", function(


scope){


这篇关于我的角度js路由不起作用。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆