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
// Simple AngularJS template filter for showing ellipses for strings of a given length | |
// | |
// USAGE IN TEMPLATE | |
// <div>{{ obj.lastname | ellipsis:10 }}</div> | |
// filter | |
app.filter('ellipsis', function() { | |
return function(input, total) { | |
if (input.length > total) { | |
return (input.slice(0, total) + "..."); |
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
WKAlertAction *action = [WKAlertAction actionWithTitle:@"OK" style:WKAlertActionStyleDefault handler:^{ | |
// do something after OK is clicked | |
}]; | |
[self presentAlertControllerWithTitle:@"Oops!" message:@"Something happened." preferredStyle:WKAlertControllerStyleAlert actions:@[action]]; | |
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
// Usage in template: My number is {{ value|abbnumber }} | |
myApp.filter('abbnumber', function() { | |
return function(input) { | |
input = parseInt(input); | |
if (input >= 10000000) { | |
return (input / 1000000).toFixed(0) + 'M' | |
} | |