Reputation: 1876
I want to escape the single quotes in the unique filter in angular but I can't, I've tried it in the following ways. If the field wouldn't have a hyphen I could do attrbutes.displayname and it will work (I've tried it), but I have a hyphen...
Example:
<select ng-model="style" ng-options="block.attributes['display-name'] for (blockName, block) in styleBlocks | unique:'attributes[\'display-name\']'">
<select ng-model="style" ng-options="block.attributes['display-name'] for (blockName, block) in styleBlocks | unique:'attributes[\\'display-name\\']'">
Upvotes: 1
Views: 289
Reputation: 24617
Use the Unicode escape \u0027
for single quotes:
'attributes[\u0027display-name\u0027]'
References
ECMAScript 2015: Table 34 — String Single Character Escape Sequences
AngularJS source: parseSpec.js - "it should tokenize unicode"
Upvotes: 1