Skip to content

Instantly share code, notes, and snippets.

@dandigangi
Created March 12, 2014 15:07
Show Gist options
  • Save dandigangi/9508854 to your computer and use it in GitHub Desktop.
Save dandigangi/9508854 to your computer and use it in GitHub Desktop.
(function ( define ) {
'use strict';
define([], function () {
var RequestService = function ( $http, $q ) {
// Return dummy data for now
return {
getListings: function () {
return [
{ propName: 'Listing 1', state: 'Illinois', city: 'Chicago' },
{ propName: 'Listing 2', state: 'New York', city: 'New York City' },
{ propName: 'Listing 3', state: 'California', city: 'San Francisco' }
];
}
};
};
return [ '$http', '$q', RequestService ];
});
}( define ));
(function ( define ) {
'use strict';
// Search Controller
define([], function ( RequestService ) {
var SearchController = function ( $scope ) {
$scope.who = 'Search Controller';
$scope.listings = RequestService.getListings();
}
return [ '$scope', SearchController ];
});
}( define ));
(function ( define, angular ) {
'use strict';
// Search Module
define([
'app/services/RequestService',
'app/controllers/SearchController',
'app/controllers/MapController'
],
function ( RequestService, SearchController, MapController) {
// String together our application into this top-level module
var moduleName = 'SearchModule';
angular.module(moduleName, [])
// Services
.service( 'RequestService', RequestService )
//Controllers
.controller( 'SearchController', SearchController )
.controller( 'MapController', MapController );
return moduleName;
});
}( define, angular ));
@ThomasBurleson
Copy link

getListings() is still synchronous. You should make it async and return a promise. I could do this for you... but it is a better learning opportunity if you try it. If you want, you can also use Plunkr to do create a live version: http://plnkr.co

@dandigangi
Copy link
Author

On it! Id rather go that route as well. Only other thing if you don't mind... is there a reason why I can't get $logs out of my app?

@dandigangi
Copy link
Author

I don't remember this at all... hahahaha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment