最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

angularJS1 url中攜帶參數(shù)的獲取方法

 更新時(shí)間:2018年10月09日 09:45:51   作者:xiejunna  
今天小編就為大家分享一篇angularJS1 url中攜帶參數(shù)的獲取方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

index.html 從此界面跳轉(zhuǎn)到a.html界面

<!doctype html>
<html>

  <head>
    <meta charset="utf-8">
    <title>form demo</title>
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <script src="js/angular.min.1.6.0.js"></script>
  </head>

  <body ng-app="app" ng-controller="myctrl">

    <button ng-click="jump()" >點(diǎn)擊跳轉(zhuǎn)下一頁(yè)</button>
    <br /><br />
    <a ng-href="a.html?name=xie&age=25&gender=nv" rel="external nofollow" >點(diǎn)擊跳轉(zhuǎn)下一頁(yè)</a>
    </div>
  </body>

  <script>
    var app = angular.module('app', []);
    app.controller('myctrl', function($scope, $window) {
      $scope.jump = function() {
        $window.location.href = 'a.html?name=xie&age=25&gender=nv';
      }
    });
  </script>

</html>

a.html 跳轉(zhuǎn)到的目標(biāo)界面,在此界面獲取url攜帶的參數(shù):

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <script src="js/angular.min.1.6.0.js"></script>
    <title></title>
  </head>
  <body ng-app="myapp" ng-controller="myctrl" >
    <p>a.html</p>


  </body>
  <script>
  //Url="http://168.33.222.69:8020/angularjs_demo/a.html?name=xie&age=25&gender=nv";
    var app=angular.module("myapp",[]);
    app.config(['$locationProvider', function($locationProvider) { 
     // $locationProvider.html5Mode(true); 
     $locationProvider.html5Mode({
     enabled: true,
     requireBase: false
    });
    }]);


    app.controller('myctrl', function($scope, $location) {


     console.log($location.search().name);
     console.log($location.search().age);
     console.log($location.search().gender);

    }); 

//打印結(jié)果:
//[Web瀏覽器] "xie" 
//[Web瀏覽器] "25" 
//[Web瀏覽器] "nv" 


  </script>
</html>

以上這篇angularJS1 url中攜帶參數(shù)的獲取方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

中阳县| 潢川县| 八宿县| 阜南县| 杨浦区| 桑日县| 新宁县| 乐平市| 龙里县| 东乌珠穆沁旗| 遵义县| 固原市| 鄂州市| 体育| 松滋市| 华宁县| 台南县| 友谊县| 敖汉旗| 唐山市| 建水县| 友谊县| 松滋市| 郁南县| 玛曲县| 儋州市| 明光市| 磐石市| 民勤县| 长垣县| 南和县| 衡阳市| 阳谷县| 理塘县| 南丰县| 海安县| 青阳县| 紫金县| 监利县| 安化县| 刚察县|