Home >Web Front-end >JS Tutorial >Simple implementation code for JS route jump

Simple implementation code for JS route jump

韦小宝
韦小宝Original
2018-01-15 11:17:521149browse

This article will share with you a simple jsroutingjump function, which is very good. Friends who are interested in js can refer to it. This is a simple js route jump. I hope it will be useful to you. help!

There are complex routing jumps in the following connection!

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="angular1.4.6.min.js"></script>
  <script src="angular-route.js"></script>
</head>
<body ng-app="MyApp" >
<a href="#/" rel="external nofollow" >CHINA</a><br/>
<a href="#/1" rel="external nofollow" >CHINA1</a><br/>
<a href="#/2" rel="external nofollow" >CHINA2</a><br/>
<a href="#/3" rel="external nofollow" >CHINA3</a><br/>
<p ng-view>
11111
</p>
<script>
  var app = angular.module("MyApp", ["ngRoute"]);
  app.config(function ( $routeProvider) {
    $routeProvider
      .when("/", {template: "<h1>123</h1>"})
      .when("/1", {template: "<h1>111</h1>"})
      .when("/2", {template: "<h1>222</h1>"})
      .when("/3", {template: "<h1>333</h1>"});
  });
</script>
</body>
</html>

The above is the simple implementation code of JS routing jump introduced by the editor. I hope it will be helpful to everyone! !

Related recommendations:

Detailed explanation of multiple inheritance examples in JavaScript

Sharing of better solutions to experience asynchronous JavaScript

javascript matches the regular expression code commented in js

The above is the detailed content of Simple implementation code for JS route jump. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn