<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>service</title> <script src="../angular-1.5.5/angular.js"></script> <script> var my=angular.module("my",[]); my.controller("mys",function ($scope, $window, $document, $location) { $scope.wHeigth=$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"); $scope.path=$location.path(); $scope.absUrl=$location.absUrl(); //设置URL中的hash部分 //获得URL }); </script> </head> <body ng-app="my" ng-controller="mys"> <p>获取屏幕的高度{{wHeigth}}</p> <p>获取屏幕的宽度{{wWidth}}</p> <p>设置title{{title}}</p> <p>URL协议部分{{protocol}}</p> <p>URL主机部分{{hostname}}</p> <p>端口号{{port}}</p> <p>URL中的hash部分{{path}}</p> <p>获得URL{{absUrl}}</p> </body> </html>
angularjs service各种服务
最新推荐文章于 2019-08-01 14:41:05 发布