$interpolate: coverage + cast to string on single token

This commit is contained in:
Evan You 2015-09-23 15:38:38 -04:00
parent ab9654b182
commit 92a62e8c2f
2 changed files with 2 additions and 1 deletions

View File

@ -119,7 +119,7 @@ exports.$interpolate = function (text) {
var vm = this
if (tokens) {
if (tokens.length === 1) {
return vm.$eval(tokens[0].value)
return vm.$eval(tokens[0].value) + ''
} else {
return tokens.map(function (token) {
return token.tag

View File

@ -145,6 +145,7 @@ describe('Data API', function () {
it('$interpolate', function () {
expect(vm.$interpolate('abc')).toBe('abc')
expect(vm.$interpolate('{{a}}')).toBe('1')
expect(vm.$interpolate('{{a}} and {{a + b.c | double}}')).toBe('1 and 6')
})