Home>

Setting jump routing in a single page

Therefore, during the development process,Encapsulate page logic into the same html. When the system loads the page for the first time,Load all pages into it,Then load it via angularjs built-in routes.

Directly on the code

Declaration app

<script type="text/javascript">
    var app=angular.module ("ngroutewxctb", ["ngroute", "ngcookies"])
    .config (["$routeprovider", function ($routeprovider) {
        $routeprovider.when ("/0", {
          templateurl:"0.html",          controller:"loginctrl"
        }). when ("/1", {
          templateurl:"1.html",          controller:"1ctrl"
        }). when ("/2", {
          templateurl:"2.html",          controller:"2ctrl"
        }). when ("/3", {
          templateurl:"3.html",          controller:"3ctrl"
        }). when ("/4", {
          templateurl:"4.html",          controller:"4ctrl"
        }). when ("/5", {
          templateurl:"5.html",//controller:"5ctrl"
        }). otherwise ({redirectto:"/login"});
      }]);
</script>

Load all views in the page

<body ng-app="ngroutewxctb">
<!-User login-start->
<script type="text/ng-template">
  <div>
  Page 0
  </div>
</script>
<!-User login-end->
<!-Join Campus-start->
<script type="text/ng-template">
  <div>
  Page 1
  </div>
</script>
<!-Join Campus-end->
<!-Cropped picture-start->
<script type="text/ng-template">
  <div>
  Page 2
  </div>
</script>
<!-Start uploading pictures-start->
<script type="text/ng-template">
  <div>
  Page 3
  </div>
</script>
<!-Start uploading pictures-end->
<!-Upload picture-start->
<script type="text/ng-template">
  <div>
  Page 4
  </div>
</script>
<!-Upload image-end->
<!-Uploading images completed-start->
<script type="text/ng-template">
  <div>
  Page 5
  </div>
</script>
<audio controls="controls"></audio>

Then jump through the route

app.controller ("loginctrl", function ($scope, $http, $interval, $cookies, $location, userservice) {
  $scope.loginsucesslocation=function () {
   var hre="./main#/1";
   location.href=hre;
  }
})
  • Previous Java batch import and export file sharing examples (compatible with xls, xlsx)
  • Next C ++ example of a static singly linked list