Created by:
Jameson Nyeholt | github.com/wintermuted
Snapflow | snapflow.com
Suggested structure from Brian Ford (Angular Team)
root-app-folder
├── index.html
├── scripts
│ ├── controllers
│ │ └── main.js
│ │ └── ...
│ ├── directives
│ │ └── myDirective.js
│ │ └── ...
│ ├── filters
│ │ └── myFilter.js
│ │ └── ...
│ ├── services
│ │ └── myService.js
│ │ └── ...
│ ├── vendor
│ │ ├── angular.js
│ │ ├── angular.min.js
│ │ ├── es5-shim.min.js
│ │ └── json3.min.js
│ └── app.js
├── styles
│ └── ...
└── views
├── main.html
└── ...
Source: http://briantford.com/blog/huuuuuge-angular-apps.html
// snapflow/app/core/controllers/users/UserManageCtrl.js
angular.module('SnapflowApp').controller('UserManageCtrl', function () {
// ...
});
// snapflow/app/core/directives/pickers/UserPicker.js
angular.module('SnapflowApp').directive('sfUserPicker', function () {
// ...
});
<div sf-user-picker="params"></div>
Give code a logic, modular separation of concerns.
angular.module('SnapApp', ['ngResource']);
angular.module('SnapApp').factory('restService', function () {
// Service Factory for interacting with the REST layer.
});
angular.module('SnapApp').factory('cacheService', function () {
// Service Factory for interacting with the in-memory cache.
});
github.com/Snapflow/AngularJS-Portland-Meetup-Slideshow
angular.module('SnapApp').factory('appService', function (restService, cacheService) {
// Service Factory for managing apps and the interacting with the cache.
var service;
service = {
app: {
get: function (appId, callback) {
restService.app.get(appId, function (appResponse) {
cacheService.app.cacheApp(appResponse, function () {
callback(appResponse);
});
});
},
}
}
return service;
});
angular.module('SnapApp').controller('appController', function ($scope, appService) {
// Controller for allowing the user to get apps.
$scope.app = null;
function getApp(appId, callback) {
appService.app.get(appId, function (response) {
$scope.app = response;
});
}
$scope.getApp = getApp;
});
Slides are available at:github.com/Snapflow/AngularJS-Portland-Meetup-Slideshow
We are currently hiring: