It's better to fail with your own error than undefined is not a function
.
A simple assertion solution would let your application fail early and fail at the right point in runtime execution. Allowing you to handle it better.
/** | |
* Fancy ID generator that creates 20-character string identifiers with the following properties: | |
* | |
* 1. They're based on timestamp so that they sort *after* any existing ids. | |
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs. | |
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly). | |
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the | |
* latter ones will sort after the former ones. We do this by using the previous random bits | |
* but "incrementing" them by 1 (only in the case of a timestamp collision). | |
*/ |
/*===================================================== | |
* | |
* Sitef Date : A javascript library that handles dates in a way that fits Sitef's needs | |
* (c) Luiz Augusto Crisostomo 2014 | |
* | |
======================================================*/ | |
function SitefDate(date) { |
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
* Anchor Smooth Scroll - Smooth scroll to the given anchor on click | |
* adapted from this stackoverflow answer: http://stackoverflow.com/a/21918502/257494 | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ | |
angular.module('yourapp').directive('anchorSmoothScroll', function($location) { | |
'use strict'; | |
return { | |
restrict: 'A', | |
replace: false, |
Angular doesn’t depend on jQuery. In fact, the Angular source contains an embedded lightweight alternative: jqLite. Still, when Angular detects the presence of a jQuery version in your page, it uses that full jQuery implementation in lieu of jqLite. One direct way in which this manifests itself is with Angular’s element abstraction. For example, in a directive you get access to the element that the directive applies to:
/* | |
* http://kevin.vanzonneveld.net | |
* original by: Webtoolkit.info (http://www.webtoolkit.info/) | |
* namespaced by: Michael White (http://getsprink.com) | |
* tweaked by: Jack | |
* improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) | |
* input by: Brett Zamir (http://brett-zamir.me) | |
* bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) | |
* depends on: utf8_encode | |
* example 1: md5('Kevin van Zonneveld'); |
var uuids = angular.module('uuids', []); | |
uuids.factory("rfc4122", function () { | |
return { | |
newuuid: function () { | |
// http://www.ietf.org/rfc/rfc4122.txt | |
var s = []; | |
var hexDigits = "0123456789abcdef"; | |
for (var i = 0; i < 36; i++) { | |
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); | |
} |
/* | |
* Curry takes a two argumented function and returns one func that returns a second func that each take one argument. | |
*/ | |
function curry (func) { | |
return function (x) { | |
return function (y) { | |
return func (x, y); | |
}; | |
}; |
<?php | |
/** | |
* Change text strings | |
* | |
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext | |
*/ | |
function my_nf_required_fields_strings( $translated_text, $text, $domain ) { | |
switch ( $translated_text ) { | |
case 'Fields marked with a * are required' : | |
$translated_text = __( '', 'ninja-forms' ); |
When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.
Raw Attribute Strings
<div my-directive="some string" another-param="another string"></div>