我想通過一個JSON對象到我的應用程序使用ng-init + stringify但它不起作用我得到一個Lexer錯誤。傳遞JSON對象到ng-init
Lexer Error: Unexpected nextharacter at columns 8-8 [#] in expression [friends=#{JSON.stringify(friends)}].
的Javascript
var friends = [
{name:'John', phone:'555-1276'},
{name:'Mary', phone:'800-BIG-MARY'},
{name:'Mike', phone:'555-4321'},
{name:'Adam', phone:'555-5678'},
{name:'Julie', phone:'555-8765'},
{name:'Juliette', phone:'555-5678'}
];
</script>
HTML
<div ng-init="friends=#{JSON.stringify(friends)}"></div>