HTML按钮怎么去棱角,重定向到一个HTML页面采用了棱角分明

我试图从productlisting.html页面重定向到search.html上的按钮,但URL在URL栏附加的点击采用了棱角分明是:重定向到一个HTML页面采用了棱角分明

/仪表板,HTML /产品清单1 html的#/#%2Fsearch.html%3Fquery =饼干

,我希望它是这样

/dashboard-html/search.html%?query=biscuits

我的代码script.js是:

Array.prototype.chunk = function (groupsize) {

var sets = [];

var chunks = this.length/groupsize;

for (var i = 0, j = 0; i < chunks; i++, j += groupsize) {

sets[i] = this.slice(j, j + groupsize);

}

return sets;

};

var data_bind=angular.module('my_app', []);

data_bind.controller('productController', function ($scope, $http, $location)

{

var isProductListingpage = false;

$scope.init = function (isProductListpage){

isProductListingpage = isProductListpage;

// if this is not search page, get the query params from url and get the products to show from server

if(!isProductListingpage)

{

var queryParam = location.search;

var request_url='http://dmsp1-kakash.boxfuse.io:9000/products?'+queryParam;

sendRequest(request_url);

}

}

function sendRequest(request_url)

{

$http({

method : 'GET',

url : request_url,

headers : {'Content-Type' : 'application/json'}

}).success(function(response){

if(response.errors){

$scope.errorName = response.errors.name ;

$scope.errorUserName = response.errors.username;

$scope.errorEmail = response.errors.email;

}

else

{

$scope.product = response.data.products;

$scope.productGroups = $scope.product.chunk(3);

}

});

}

$scope.search_field={};

$scope.searchdata= function()

{

var queryParam = "query="+encodeURI($scope.search_field.search);

var request_url='http://dmsp1-kakash.boxfuse.io:9000/products?'+queryParam;

// If this is product listing page, we need to redirect to search page,

// otherwise make a request to server

if(isProductListingpage) {

//$window.location.href = '/index.html'

$location.url('#/search.html?'+queryParam);

}

else {

sendRequest(request_url);

}

}

$scope.search_field1={};

$scope.search_page= function(event)

{

var $target = $(event.target);

if($target.hasClass('sub-category'))

{

var subCategory = $target.clone() //clone the element

.children() //select all the children

.remove() //remove all the children

.end() //again go back to selected element

.text();

var $temp = $target.closest('.submenu');

var $mainCategoryElement = $temp.siblings('.main-category').first();

var mainCategory = $mainCategoryElement.text();

// Encode both the values

subCategory = encodeURI(subCategory);

mainCategory = encodeURI(mainCategory);

var queryParam = 'cat='+mainCategory+"&subcat="+subCategory;

var request_url='http://dmsp1-kakash.boxfuse.io:9000/products?'+queryParam;

// If this is product listing page, we need to redirect to search page,

// otherwise make a request to server

if(isProductListingpage) {

$location.url('#/search.html?'+queryParam);

}

else {

sendRequest(request_url);

}

}

}

});``

2016-05-19

kriti

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值