AngularJS templates can't use JSON that contains hyphen -


angularjs templates can't use json contains hyphen in key.

e.g.

my json looks

{    ...    link: {        xx-test:{             href: '/test/xx'          } } 

now, in angularjs template if refer href not working

<a ng-href="/app/edit?item={{item.link.xx-test.href}}"></a> 

it unable resolve value href rendered /app/edit?item=

it tried

<a ng-href="/app/edit?item={{'item.link.xx-test.href'}}"></a> <a ng-href="/app/edit?item={{item.link.xx\-test.href}}"></a> <a ng-href="/app/edit?item={{item.['link.xx-test'].href}}"></a> 

the object key needs quoted with:

$scope.bar = {'xx-test':'foo'}; 

bracket notation should used in angular expression.

<p>{{bar['xx-test']}}</p> 

you can optionally escape hyphen \- in angular expression.


Comments

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -