Created
July 25, 2016 09:58
-
-
Save carlqt/15b375563a12c472313b888b81cac805 to your computer and use it in GitHub Desktop.
Sample angularjs code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newApp.controller('newAppController', function newAppController($scope, $http) { | |
$scope.locations = {} | |
$http.get("/api/properties").success(function(data) { | |
$scope.locations = data; | |
}); | |
$scope.searchNearby = function($event){ | |
var keyCode = $event.which || $event.keyCode; | |
if (keyCode === 13) { | |
var config = { | |
headers: { | |
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;' | |
} | |
} | |
$http.post('/api/property', "location=" + $event.currentTarget.value, config) | |
.success(function(data, status, header){ | |
debugger; | |
console.log("created"); | |
}) | |
.error(function(data, status, header){ | |
console.log("Failed"); | |
}) | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment