javascript - Angularjs Get url parameters and call function -


i have 2 different pages , want pass variable url. created function read parameters , load data.

    $(document).ready(function() {         $scope.getitemsinsubcat(getparameterbyname('catid'),getparameterbyname('subid'));      });                       $scope.getitemsinsubcat = function(catid, subcatid) {            console.log(catid);       var productsinsubcategorydbref = firebase.database().ref().child('productsincategory/').child(catid).child(subcatid).child('astana')       productsinsubcategorydbref.once('value', snap => {         $scope.items = [];         snap.foreach(function(childsnap){           var item = {};             //console.log(childsnap.val().photos[object.keys(childsnap.val().photos)[0]]);             item = childsnap.val();             item["mainphoto"] = childsnap.val().photos[object.keys(childsnap.val().photos)[0]];             $scope.items.push(item);             $scope.currentcat=item.categoryname;             $scope.currentsubcat=item.subcategoryname;                 $scope.$apply();          });        console.log($scope.items);       });         function getparameterbyname(name, url) {         if (!url) url = window.location.href;         name = name.replace(/[\[\]]/g, "\\$&");         var regex = new regexp("[?&]" + name + "(=([^&#]*)|&|#|$)"),             results = regex.exec(url);         if (!results) return null;         if (!results[2]) return '';         return decodeuricomponent(results[2].replace(/\+/g, " "));     } 

it works fine if call function pasting ids without parsing url:

$scope.getitemsinsubcat('-kqje8qimuvrggsmggj4','-kqjea6_cbnin3979obc');  

i dont want use $routeparams.

anyone knows problem?

thanks in advance!


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -