Created
October 8, 2014 22:39
-
-
Save Ollo/c21c8ff32c59d728c462 to your computer and use it in GitHub Desktop.
angular module pattern example
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
// user-profile-controller.js | |
define([ | |
'angular', | |
'components/userProfile/user-profile-factory.js', | |
'components/userProfile/user-profile-directives.js', | |
], | |
function(){ | |
'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