You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Extend interpolation with MessageFormat like syntax.
Ref: <https://docs.google.com/a/google.com/document/d/1pbtW2yvtmFBikfRrJd8VAsabiFkKezmYZ_PbgdjQOVU/edit>
Example:
```html
{{recipients.length, plural, offset:1
=0 {You gave no gifts}
=1 { {{ recipients[0].gender, select,
male {You gave him a gift.}
female {You gave her a gift.}
other {You gave them a gift.}
}}
}
one { {{ recipients[0].gender, select,
male {You gave him and one other person a gift.}
female {You gave her and one other person a gift.}
other {You gave them and one other person a gift.}
}}
}
other {You gave {{recipients[0].gender}} and # other people gifts. }
}}
```
This is a SEPARATE module so you MUST include
angular-messageformat.min.js. In addition, your application module
should depend on the "ngMessageFormat".
(e.g. angular.module('myApp', ['ngMessageFormat']);)
$interpolate automatically gets the new behavior.
Quick note on syntax differences from MessageFormat:
- MessageFormat directives are always inside {{ }} instead of
single { }. This ensures a consistent interpolation syntax (else you
could interpolate in more than one way and have to pick one based on
feature availability for that syntax.)
- The first word inside such syntax can be an arbitrary Angular
expression instead of a single identifier.
- You can nest them as deep as you want. As mentioned earlier, you
would use {{ }} to start the nested interpolation that may optionally
include select/plural extensions.
- Only "select" and "plural" keywords are currently recognized.
- Quoting support is coming in a future commit.
- Positional arguments/placeholders are not supported. They don't make
sense in Angular templates anyway (they are only helpful when using
API calls from a programming language.)
- Redefining of the startSymbol and endSymbol used for interpolation is
not currently supported yet.
You've just hit a bug in the ngMessageFormat module provided by provided by
7
+
angular-messageFormat.min.js. Please file a github issue for this and provide the interpolation text that caused you to hit this bug mentioning the exact version of AngularJS used and we will fix it!
8
+
9
+
For more information about the MessageFormat syntax in interpolation
10
+
expressions, please refer to MessageFormat extensions section at
@fullName MessageFormat extensions not allowed in secure context
4
+
@description
5
+
6
+
You have attempted to use a MessageFormat extension in your interpolation expression that is marked as a secure context. For security purposes, this is not supported.
7
+
8
+
Read more about secure contexts at {@link ng.$sce Strict Contextual Escaping
9
+
(SCE)} and about the MessageFormat extensions at {@link
0 commit comments