Skip to content

Instantly share code, notes, and snippets.

View 0x-r4bbit's full-sized avatar

r4bbit 0x-r4bbit

View GitHub Profile
@0x-r4bbit
0x-r4bbit / directive.js
Created February 19, 2013 10:39
AngularJS Zippy
'use strict';
myApp.directive('zippy', function(){
return {
restrict: 'E',
transclude: true,
scope: { title:'@title' },
template:
'<div class="zippy {{state}}">' +
'<div class="title" ng-click="toggle()">{{title}}</div>' +
@0x-r4bbit
0x-r4bbit / breadcrumbs.js
Created March 11, 2013 08:27
Breadcrumb Servive for angular apps.
angular.module('services.breadcrumbs', []);
angular.module('services.breadcrumbs').factory('breadcrumbs', ['$rootScope', '$location', function ($rootScope, $location) {
var breadcrumbs = [];
var breadcrumbsService = {};
$rootScope.$on('$routeChangeSuccess', function (event, current) {
var pathElements = $location.path().split('/'), result = [], i;
@0x-r4bbit
0x-r4bbit / proposal.md
Last active May 2, 2022 03:50
Proposals on how to structure 'standalone' modules in angular. Please read it and leave your opinions for a better angularjs world!

Angular module structure (proposal)

Everyone who's reading this, please leave your opinion/ideas/proposals as a comment for a better world!

Background

Most of you guys read Josh' proposals to make components more reusable, I think. Now, reading through this proposals definitely gives a feeling that this is the right way. Anyways, If you haven't read it yet, you should.

So Josh shows us, how angular apps can be structured in a better and more reusable way. Reusability is a very important thing when it comes to software development. Actually the whole angularjs library follows a philosophy of reusability. Which is why you able to make things like:

describe('useLocalStorage()', function () {
beforeEach(module('pascalprecht.translate', 'ngCookies', function ($translateProvider) {
// ensure that the local storage is cleared.
window.localStorage.clear();
$translateProvider.translations('de_DE', {
'EXISTING_TRANSLATION_ID': 'foo',
'ANOTHER_ONE': 'bar',
'TRANSLATION_ID': 'Lorem Ipsum {{value}}',
'TRANSLATION_ID_2': 'Lorem Ipsum {{value}} + {{value}}',
var promiseToWaitFor = (function () {$
var promise = $preferredLanguage ?$
langPromises[$preferredLanguage] :$
langPromises[$uses];$
$
if (!promise) {$
promise = langPromises[Storage.get($storageKey)];$
}$
return promise;$
}());
import {JoinFilterModule} from '../../common/join_filter';
import './country_info_table.tpl.html';
export let CountryInfoTableModule = angular.module('CountryInfoTable', [JoinFilterModule.name, 'templates'])
.directive('countryInfoTable', () => {
return {
restrict: 'E',
templateUrl: 'country_info_table.tpl.html',
scope: {},
var sortedByVoteCount;
var oReq = new XMLHttpRequest();
function reqListener () {
sortedByVoteCount = JSON.parse(JSON.stringify(oReq.response))
.posts.sort(function (a, b) {
if(a.vote_count < b.vote_count) return -1;
if(a.vote_count > b.vote_count) return 1;
return 0;
});
@NgModule({
providers: []
})
export class ConfiguredAngularFireModule {
configure(config) {
return AngularFireModule.initializeApp(config, {
provider: AuthProviders.Password,
method: AuthMethods.Password
});
}
Verifying my Blockstack ID is secured with the address 18tAfJrheJEtWRKeDA5rbdgEShvYz77FKC https://explorer.blockstack.org/address/18tAfJrheJEtWRKeDA5rbdgEShvYz77FKC

Keybase proof

I hereby claim:

  • I am pascalprecht on github.
  • I am pascalprecht (https://keybase.io/pascalprecht) on keybase.
  • I have a public key ASDQ0OWA3wX08_2ABLEEL3wqvNZHwBWeoZFfxHH6Ymy3Awo

To claim this, I am signing this object: