Here's what I'm trying to do:
Below is what I've tried so far, which has given me the following error:
Uncaught object angular.js:78
Main.html (1):
<div class="input-group input-group-lg">
<input ng-model="businessName" type="text" class="form-control" placeholder="Business Name">
</div>
google.js (2):
var findGPlace2 = function() {
GoogleService.findPlace2($scope.businessName).then(function(data) {
$scope.gPlace2 = data;
});
}
findGPlace2();
google-service.js (3):
this.findPlace2 = function(biz){
var deferred = $q.defer();
var obj = {
business: biz
};
$http(
{
method: 'GET',
url: 'http://localhost:12200/find-google-place-2',
data: biz
}).success(function(data) {
deferred.resolve(data);
}).error(function(err) {
deferred.reject(err);
});
return deferred.promise;
};
server.js (4):
//find google place 2
app.get('/find-google-place-2', function(req, res) {
request('https://maps.googleapis.com/maps/api/place/textsearch/json?query=' + req.data.biz + '&key=AIzaSyBvakIQ68QV2', function (error, response, body) {
if (!error && response.statusCode == 200) {
res.send(body);
}
})
});
This is a very difficult problem to debug since the error isn't giving me a line in my code. Any help would be greatly appreciated.
==================================================
==================================================
UPDATE:
I removed ng-autocomplete from the dependencies, and the Uncaught object error is gone and my angular code is rendering now, but this error came up:
GET http://localhost:12200/find-google-place-2 500 (Internal Server Error) angular.js:8380
(anonymous function) angular.js:8380
sendReq angular.js:8180
$http.serverRequest angular.js:7921
I'm sure it has to do with how I'm passing my req data (the string from the text input), here is the function:
this.findPlace2 = function(biz){
var deferred = $q.defer();
var obj = {
business: biz
};
$http(
{
method: 'GET',
url: 'http://localhost:12200/find-google-place-2',
data: biz
}).success(function(data) {
deferred.resolve(data);
}).error(function(err) {
deferred.reject(err);
});
return deferred.promise;
};
Here's where it's actually running in my server.js file:
app.get('/find-google-place-2', function(req, res) {
request('https://maps.googleapis.com/maps/api/place/textsearch/json?query=' + req.data.biz + '&key=AIzaSyBvakIQ68QV2', function (error, response, body) {
if (!error && response.statusCode == 200) {
//console.log(body)
res.send(body);
}
})
});
There isn't really enough to go on with what you've given me, but here are some suggestions on how to go about debugging:
This is almost definitely (my guess) an error in passing in the required dependencies to the module (ngRoute the most common, but anything else that is required will throw that uncaught object error):
var app = angular.module('app', ['ngRoute']);
If that is not a simple fix for you, a way to get an actual debug message easily is to use an unminified source for angular, and run it in Chrome Canary build.