如何在使用 angular js 路由的页面中创建 <a> link 标记?
how to create an <a> link tag in a page that uses angular js routing?
我正在使用 Angular JS 路由。
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl : "index.htm"
})
.when("/second", {
templateUrl : "second.html",
controller : "secondCtrl"
})
.when("/third", {
templateUrl : "third.html",
controller : "thirdCtrl"
});
});
app.controller("secondCtrl", function ($scope) {
$scope.msg = "in second controller";
});
app.controller("thirdCtrl", function ($scope) {
$scope.msg = "in third controller";
});
如何在我的 html 中创建一个 link 到 link 到路由中的 /second link?
我回答了我自己的问题。
可以使用下面形式的link来访问上例中的/second路由
<a href="#!/second" >Second</a>
我正在使用 Angular JS 路由。
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl : "index.htm"
})
.when("/second", {
templateUrl : "second.html",
controller : "secondCtrl"
})
.when("/third", {
templateUrl : "third.html",
controller : "thirdCtrl"
});
});
app.controller("secondCtrl", function ($scope) {
$scope.msg = "in second controller";
});
app.controller("thirdCtrl", function ($scope) {
$scope.msg = "in third controller";
});
如何在我的 html 中创建一个 link 到 link 到路由中的 /second link?
我回答了我自己的问题。
可以使用下面形式的link来访问上例中的/second路由
<a href="#!/second" >Second</a>