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 angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to