If you are doing this for translation I suggest:
https://angular-translate.github.io/docs/#/api/pascalprecht.translate.filter:translate
{{'hello' | translate}}
{{ myVar | translate}}
<span translate="NAME"></span>
https://angular-translate.github.io/
On Tuesday, April 5, 2016 at 5:06:17 PM UTC-5, Paul Selden wrote:
>
> Is there a way to control what gets output for a custom object in an
> angular expression? I was hoping that overriding the valueOf function would
> work, but unfortunately it displays it as an object:
>
> // js
> function SuperString(string) {
> this._string = string;
> }
>
> SuperString.prototype.valueOf = function() {
> return 'Super ' + this._string;
> };
>
> var superString = new SuperString('String');
> $scope.superString = superString;
>
> // html
> <div>{{ superString }}</div>
>
> // expected
> <div>Super String</div>
>
> // actual
> <div>{ "_string": "String"}</div>
>
>
> Any ideas about a way around this? My actual use case was for a wrapper
> around a string that automatically returns the translated value if one
> exists.
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.