当前位置:首页 >> 网络编程

angular.js 路由及页面传参示例

页面传参数方法:1、$rootScope。2、(url)/user/:name/:age。

页面转换方法:1、href="#/" rel="external nofollow" rel="external nofollow" rel="external nofollow" 。2、$state.Go。3、$location.path。4、ui-sref

(1)自带路由ngRoute

<html> 
  <head> 
    <meta charset="utf-8"> 
    <title>AngularJS 路由实例</title> 
  </head> 
  <body ng-app='routingDemoApp' ng-controller="myCtrl"> 
    <h2>AngularJS 路由应用</h2> 
       名: <input type="text" ng-model="names"><br> 
    <ul> 
      <li><a href="#/" rel="external nofollow" rel="external nofollow" rel="external nofollow" >首页1</a></li> 
      <li><a href="#/second/2/3" rel="external nofollow" >second</a></li> 
      <li><a href="#/printers" rel="external nofollow" >打印机</a></li> 
      <li><a href="#/blabla" rel="external nofollow" >其他</a></li> 
    </ul> 
    <div ng-view></div> 
    <script src="/UploadFiles/2021-04-02/jquery.min.js">

(2)ui-router

<html> 
  <head> 
    <meta charset="utf-8"> 
    <title>AngularJS 路由实例 </title> 
     <script src="/UploadFiles/2021-04-02/angular.min.js">

下载地址:angu_demo_jb51.rar

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。