正如我的标题所说,$location.search 不会重新加载页面,它只是更新 URL。我的代码:
var app = angular.module('myApp', [], function($locationProvider) {
$locationProvider.html5Mode(true);
});
app.controller('mytableCtrl', function($scope, $location, $http) {
$scope.target = $location.search()["categoryid"];
$http.get("api/topCategories")
.success(function(response) {$scope.names = response;});
});
有什么建议吗?这段代码有其他选择吗?
编辑: $location.search 在category.html?categoryid=any_number 中搜索参数。它需要任何_number数字并且必须将其与另一个值进行比较。但是,我尝试按任何 a href,它只会更新 URL,但不会重新加载页面。
最佳答案
我刚刚在 href 标签中添加了 target="_self",它工作得很好。
关于javascript - AngularJS $location.search 不重新加载页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31455548/