app.controller('GetData', function ($scope, $location, $routeParams)
{
var searchObject = $location.search();
$scope.isActiveFromLocation = (searchObject.state == "active");
$scope.isActiveFromRoute = ($routeParams.state == "active");
}
在上面的代码中,我试图通过angularjs从url querystring www.testsite.com/#xyz?state=active获取数据。我调试并发现两个范围变量都显示相同的结果。在这种情况下哪个选项最好读取查询字符串值?有什么建议。