JAVASCRIPT CODE:
<script>
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
var user = getUrlVars()["user"];
var pass = getUrlVars()["pass"];
var sub = getUrlVars()["sub"];
</script>
<script>
var myApp = angular.module('myApp',[]);
myApp.controller('dropdownCtrl', ['$scope','$window','$http', function($scope, $window, $http) {
$http.get('http://dummy.com/app/chapter.php?user='+user+'&pass='+pass)
.then(function (response) {$scope.names = response.data.admin;});
$scope.names = [];
$http.get('http://dummy.com/app/chapter.php?user='+user+'&pass='+pass+'&sub='+sub)
.then(function (response) {$scope.chapter = response.data.chp;});
$scope.chapter = [];
};
}]);
</script>
HTML:
<div ng-controller="dropdownCtrl">
<div ng-repeat="a in chapter">
<a href="topic.html?ch={{a.chapter}}" onClick="location.href=this.href+'&user='+user+'&pass='+pass+'&sub='+sub;return false;">{{a.chapter}}</a>
</div>