Skip to content

Instantly share code, notes, and snippets.

@nicovalencia
Forked from Ollo/angular-modules.js
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicovalencia/398f4f7d26a4ab1eaf6e to your computer and use it in GitHub Desktop.
Save nicovalencia/398f4f7d26a4ab1eaf6e to your computer and use it in GitHub Desktop.
0
/*
* Example directory/file structure:
*
* app
* |-- components/
* | └-- user-profile/
* | |-- user-profile.js
* | |-- user-profile-directives.js
* | └-- user-profile-services.js
* └-- main.js
*
*/
// user-profile.js
define([
'angular',
'./user-profile-services.js',
'./user-profile-directives.js'
],
function(angular, services, directives){
'use strict';
var module = angular.module('userProfile.module', ['userProfile.directives', 'userProfile.factory']);
module.controller('userProfileController', ['$scope', 'userProfileDirectives', 'userProfileFactory', function($scope, userProfileDirectives, userProfileFactory){
$scope.userfunctionthings() {
...
}
}]);
});
// user-profile-directives.js
define([
'angular',
'common/other-directive'
],
function(){
'use strict';
var module = angular.module('userProfile.directives' ['common.other-directive']);
module.directive('userProfileNav', [ function(){
return {
// directive definition
...
};
}]);
});
// user-profile-factory.js
define([
'angular',
'ng-resource'
],
function(){
'use strict';
var module = angular.module('userProfile.factory', ['ngResource']);
var module.factory('userProfileFactory', ['$resource', function($resource){
return {
getUser: function() {
return $resource('api/user/:id', {id: '@id'});
}
};
}]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment