Skip to content

Instantly share code, notes, and snippets.

@Ntropish
Created July 24, 2015 03:13
Show Gist options
  • Save Ntropish/c33b77e11c3cdc0065fd to your computer and use it in GitHub Desktop.
Save Ntropish/c33b77e11c3cdc0065fd to your computer and use it in GitHub Desktop.
extends layout
block scripts
script(src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js")
script(src="javascripts/index.js")
block content
div(ng-app="nightlife" ng-controller="NightlifeCtrl as nl")
button(class="btn" ng-click="findBars()")
| Find local bars
div(ng-repeat="bar in bars")
h4.ng-cloak {{ bar.name }}
angular.module('nightlife', [])
.controller('NightlifeCtrl', ['$scope', function ($scope) {
$scope.bars = [{name: 'ayo'}];
$scope.user = {};
$scope.latLong = '';
function getLocation() {
navigator.geolocation.getCurrentPosition(function (position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
$scope.latLong = latitude + ',' + longitude;
});
}
getLocation();
$scope.findBars = function findBars() {
if ($scope.latLong) {
$.ajax('/city',
{
type: 'GET',
data: {
location: $scope.latLong
},
success: function(res){
$scope.$apply(function(){
$scope.bars = res;
})
}
}
);
}
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment