以下脚本在head中的目的是什么?
使用以下控制器:
<head>
<script>document.write('<base href="' + document.location + '" />');</script>
...
</head>
我有点理解基本href用于设置默认路径的初始部分。那么这会将URL设置到哪里呢? 稍后,我会使用
<body ng-app="plunker" ng-controller="NavCtrl">
<p>Click one of the following choices.</p>
<ul>
<li ng-class="{active: isActive('/tab1')}"><a href="#/tab1">tab 1</a></li>
<li ng-class="{active: isActive('/tab2')}"><a href="#/tab2">tab 2</a></li>
</ul>
<pre>{{ path }}</pre>
</body>
使用以下控制器:
var app = angular.module('plunker', []);
app.controller('NavCtrl', function($scope, $location) {
$scope.isActive = function(route) {
$scope.path = $location.path();
return $location.path() === route;
};
});