A; B Run A and then B, regardless of success of A
A && B Run B if A succeeded
A || B Run B if A failed
A & Run A in background.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('testModulePleaseIgnore', []) | |
app.component('legalReferences', { | |
bindings: { | |
foo: '&?', | |
bar: '<?', | |
baz: '=?', | |
qux: '@?' | |
}, | |
controller: function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('app', []) | |
app.component('selectPicker', { | |
template: '<div ng-transclude ng-show="$ctrl.show"></div>', | |
require: { | |
ngModel: '^ngModel' | |
}, | |
bindings: { | |
options: '<', | |
disable: '<' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://developer.mozilla.org/en-US/docs/Web/API/Location | |
// Source: https://developer.mozilla.org/en-US/docs/Web/API/Window/location | |
// Navigate to a new page. | |
window.location.assign('http://www.mozilla.org') | |
// Force reloading the current page from the server | |
// **Note:** If the parameter is not set or set to false then the browser may | |
// reload from cache | |
window.location.reload(true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('example', []); | |
app.component('foo', { | |
require: { | |
theModel: '^ngModel' | |
}, | |
template: '[...]', | |
controller: FooCtrl, | |
bindings: { | |
options: '<' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {string} url | |
*/ | |
function removeTrailingSlashes(url) { | |
return url.replace(/\/+$/, ''); //Removes one or more trailing slashes from URL | |
} |
Often times the choice between both directives seems trivial, because you can achieve the same effect either way. However both have interesting default behaviours that you can use to you advantage.
ng-show
will hide the element it is on by default, unless the condition in it evaluates to true.ng-hide
will show the element it is on by default, unless the condition in it evaluates to true.
This is most useful when your controller is doing AJAX calls or something else that's asynchronous. Your variables may still be undefined until the AJAX call returns.
foo.controller.js
$ctrl.foos;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Node { | |
//... | |
} | |
export class UnidirectionalNode extends Node { | |
private next: Node; | |
//... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.get('/html/template01.html').done(function(html) { | |
var template = $(html); //Create DOM element | |
//Do stuff with the new DOM element | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="item-with-actions"> | |
<i class="primary"> | |
This is the primary content of the item | |
</i> | |
<div> | |
<button> | |
Edit | |
</button> | |
</div> | |
<div> |