Angular $location獲取端口號
阿新 • • 發佈:2017-08-04
n) handle har utf port fun ctr rip sco
<!DOCTYPE html>
<html ng-app="myApp">
<head lang="en">
<meta charset="UTF-8">
<script src="js/angular.js"></script>
<title></title>
</head>
<body>
<div ng-controller="myCtrl">
<p>{{nowPort}}</p>
<button ng-click="handleClick()">
得到端口號
</button>
</div>
<script>
var app = angular.module(‘myApp‘, [‘ng‘]);
app.controller(‘myCtrl‘, function ($scope,$location) {
$scope.nowPort = "";
$scope.handleClick = function () {
//獲取端口號
$scope.nowPort = $location.port();
}
})
</script>
</body>
</html>
Angular $location獲取端口號