Created
March 12, 2014 15:07
-
-
Save dandigangi/9508854 to your computer and use it in GitHub Desktop.
This file contains 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
(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 )); |
This file contains 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
(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 )); |
This file contains 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
(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 )); |
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?
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
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