Skip to content

Instantly share code, notes, and snippets.

@ansmith
ansmith / OverviewSection.js
Created March 28, 2013 16:39
Basic renderTpl approach for sections of the overview panel
/**
*
*/
Ext.define('Oxford.view.base.OverviewSection', {
extend: 'Ext.Component',
/**
* @cfg {String} sectionName
*/
sectionName: 'Section',
@ansmith
ansmith / Angular Service
Last active August 29, 2015 13:56
This is a sample Angular service, designed to expose only as much as desired and to be able to easily call "public" and "private" functions easily from within the service.
myApp.factory('MyService', function($http, $q) {
//Local vars
var state = {};
//Publicly exposed functions
var me = function() {};
me.prototype = {
getState: function(key) {
return state[key];
describe("MyService", function() {
'use strict';
var service;
beforeEach(module('myApp'));
beforeEach(inject(function($templateCache) {
//Whatever the default route is, needs to be cached so $httpBackend doesn't see other requests
$templateCache.put('views/default.html', __html__['src/main/webapp/views/default.html']);
myApp.controller('AbstractWidgetControl', function($scope) {
$scope.errorMaskVisible = false;
$scope.errorMessage = '';
$scope.showErrorMask = function(message) {
$scope.errorMessage = message || 'Unknown error occurred';
$scope.errorMaskVisible = true;
};
$scope.hideErrorMask = function() {
myApp.controller('MyWidgetControl', function($scope, $controller) {
$controller('AbstractWidgetControl', {$scope: $scope});
//"Public" functions
$scope.myFunction = function() {
//...
};
//Private functions
function myPrivateFn() {
<div class="widget" ng-controller="WidgetControl">
<h2>My Widget</h2>
<!-- ... -->
<widget-error-mask></widget-error-mask>
</div>
myApp.directive('widgetErrorMask', function() {
return {
restrict: 'E',
replace: 'true',
transclude: true,
template: '<div class="error-mask" ng-show="errorMaskVisible"><div>{{errorMessage}}</div></div>'
};
});