Promises and $resource [coach]
https://docs.angularjs.org/api/ngResource/service/$resource
Model.io : keep an eye on it [team]
http://browsenpm.org/package/model.io https://github.com/model-io/model.io model.io tries to be a thin layer between frontend and backend by only sharing models and data. This is done throught websockets bases on sock.js and a small multi-channel-layer sock-channels.
Implementing the IndexedDB Factory [team]
Using the IndexedDB Factory is not a complete example with querying, but simply a brute force approach to dumping and retrieving data through the IndexedDB Factory for the moment. We will refine this later. angular.module(‘todomvc’) .service(‘todoModel’, [‘$rootScope’, ‘todoREST’, ‘indexedDBDataService’, function … Continued
IndexedDB Factory in AngularJS [team]
The Factory angular.module(‘todomvc’) .factory(‘indexedDBDataService’, [‘$window’, ‘$q’, function ($window, $q) { var indexedDB = $window.indexedDB; var db = null; var lastIndex = -1; var open = function () { var deferred = $q.defer(); var version = 1; var request = indexedDB.open(“todoData”, … Continued
Notifications in Web Apps [architect]
Long polling To be able to immediately notify a client that something changed, we need a connection to that client. Since web browsers do not traditionally accept connections and clients are usually behind devices that would block such connections anyway, … Continued
Filtering in your Angular Model [team]
Assume you loaded all the todos into an array in the model // model var todos; var todosFilterd; function getAllTodos(){ todoREST.getAll().then(function(result) { $rootScope.$broadcast(‘todoModel::gotTodosFromRestEvent’); transformTitles(result.data); todos = result.data; }); } function filterTodos() { this.todosFilterd = this.todos.filter(function (val) { return val.completed === … Continued
Rest Call in Model with Event to Controller in AngularJS [team]
This is a Model loading the REST data and firing an event. The Controller listens for that event and assigns the Model STATE to $scope. // Controller angular.module(‘todomvc’) .controller(‘TodoCtrl’, function TodoCtrl($scope, $routeParams, $filter, todoEntity, todoREST, todoModel) { ‘use strict’; $scope.$on(‘todoModel::gotTodosFromRestEvent’, … Continued
Events from Model to Controller in Angular [team]
This is how an event is triggered in the Model and Caught in the Controller. // Model angular.module(‘todomvc’) .service(‘todoModel’,[‘$rootScope’, function ($rootScope) { ‘use strict’; var todos; function clearCompletedTodos () { this.todos = this.todos.filter(function (val) { return !val.completed; }); $rootScope.$broadcast(‘todoModel::clearCompletedTodosEvent’); … Continued
The World’s Largest Ball of Events [architect]
If you try to unwind the flow of control through your $broadcast()/$emit()/$on() and keep losing your place, you have too many events*. Events (or “PubSub” or whathaveyou) are tools to use when you either don’t know or don’t care what’s … Continued