angularjs 서비스는 화면 너비, URL, 본 컴퓨터의 주소를 가져옵니다.

6488 단어
/span>html>
<html ng-app="myapp">
<head>
    <meta charset="UTF-8">
    <title> servicetitle>
    <script src="angular-1.3.0.js">script>
    <script>
        var my=angular.module("myapp",[]);
        my.controller("myCtrl",function($scope,$window,$document,$location){
            $scope.wHeight=$window.innerHeight;
            $scope.wWidth=$window.innerWidth;
            //------------------------------------------- title
            //$document[0].title=" ";
            $scope.title=$document[0].title;
            $scope.protocol=$location.protocol();//--------URL 
            $scope.hostname=$location.host();//------------URL 
            $scope.port=$location.port();//---------------- 
            $location.path("aaa");//----------------------- URL  hash 
            $scope.path=$location.path();
            $scope.absUrl=$location.absUrl();//------------- URL
        })
    script>
head>
<body ng-controller="myCtrl">
<p> {{wHeight}}p>
<p> {{wWidth}}p>
<p> title{{title}}p>
<p> url {{protocol}}p>
<p> url {{hostname}}p>
<p> {{port}}p>
<p> hash {{path}}p>
<p> {{absUrl}}p>
body>
html>

좋은 웹페이지 즐겨찾기