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
Post a Comment