Skip to content

Instantly share code, notes, and snippets.

View icfantv's full-sized avatar

Adam Gordon icfantv

View GitHub Profile
@icfantv
icfantv / template.html
Last active March 24, 2016 16:07
Form Error Reporting in Angular
<ng-form name="shoeData">
<div class="container-fluid">
<div class="form-group col-sm-3 col-md-3 col-lg-3"
ng-class="{ 'has-error': shoeData.shoeName.$touched && shoeData.shoeName.$invalid }">
<label for="shoe-name" class="control-label">
Name: <span class="text-danger">*</span>
</label>
<input id="shoe-name"
type="text"
autocomplete="off"
@icfantv
icfantv / app.js
Created March 22, 2016 23:37
Webpack FTW
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';
import 'font-awesome/css/font-awesome.css';
import 'angular-ui-tree/dist/angular-ui-tree.css';
import './main.css';
import angular from 'angular';
import ngAnimate from 'angular-animate';
import ngSanitize from 'angular-sanitize';
import ngRoute from 'angular-route';
@icfantv
icfantv / structure.txt
Created March 18, 2016 16:38
Application Structure
Top Level Dir
index.html
app.js (or similar)
- dashboard
index.js
- controllers
DashboardController.js
...
- services
DashboardService.js
@icfantv
icfantv / BadPromise.js
Last active April 13, 2016 14:56
How to NOT do a nested promise
someFunction() {
// do some stuff
MyService.doSomething().then(() => {
// do some stuff
AnotherService.doSomethingElse().then((blah) => {
export class ExampleService {
static get $inject() {
return ['$http'];
}
constructor($http) {
this.$http = $http;
}
@icfantv
icfantv / app.js
Created February 25, 2016 00:53
Angular HTTP Interceptors
var app = angular.module('app', []);
app.config(['$httpProvider', ConfigureInjectors]);
function ConfigureInjectors($httpProvider) {
$httpProvider.interceptors.push('InterceptorService');
}
app.service('InterceptorService', ['$cookie', InterceptorService]);
function InterceptorService($cookie) {
this.request = function(config) {
@icfantv
icfantv / ISSUE_TEMPLATE.md
Created February 18, 2016 01:50
UIBS ISSUE_TEMPLATE.md

Uh oh! So you think you found an issue? We're so embarrassed. Prior to entering anything, please ensure you've read CONTRIBUTING.md as the issues forum is for bugs only and not for suppor-related requests. Support-related requests are best served by and for the community at large. Additionally, please note that we do not release patches for older versions of the library but we have provided some documentation history via the "Previous docs" dropdown on [our demo site] (http://angular-ui.github.io/bootstrap).

If you're upgrading from an older version of the library and you're experiencing console errors or other issues, please make sure you read through the CHANGELOG.md starting with the version from which you're upgrading. Pay particular attention to the breaking changes sections

@icfantv
icfantv / SampleRouteConfiguration.js
Created February 12, 2016 20:23
Sample Route Provider
export function SampleRouteConfiguration($routeProvider) {
$routeProvider.when('/customer', {
controller: 'CustomerListController',
controllerAs: 'customers',
templateUrl: 'path/to/customers.html',
resolve: {
consumers: ['CustomerService', CustomerService => CustomerService.getAll()]
}
}).when('/customer/:id', {
controller: 'CustomerController',
@icfantv
icfantv / MyDirective.js
Created February 4, 2016 02:17
ES6 modules, Angular Directives, and you
export function MyDirective() {
return {
restrict: 'E',
controller: 'MyDirectiveController',
controllerAs: 'snoopy',
scope: {
stuff: '=yoGimmeSomeStuff'
},
templateUrl: 'components/snoopy/views/gimme-some-stuff-template.html'
};
@icfantv
icfantv / function.js
Last active February 10, 2016 19:40
Username Validation
vm.username = function($viewValue, $modelValue, scope) {
// check if username matches regex before validating
var value = $modelValue || $viewValue, deferred = $q.defer();
if (UserConfig.ID_REGEX.test(value)) {
scope.options.templateOptions.loading = true;
UserService.username(value).then(function() {
deferred.reject(false);