Smarty PHP clashing with AngularJS

一曲冷凌霜 提交于 2019-12-03 07:25:18

Try this:

<li ng-repeat="i in items">
    <p class="item">{literal}{{i}}{/literal}</p>
</li>

Quote from Smarty site...

{literal} tags allow a block of data to be taken literally. This is typically used around Javascript or stylesheet blocks where {curly braces} would interfere with the template delimiter syntax. Anything within {literal}{/literal} tags is not interpreted, but displayed as-is.

Much cleaner solution: You can change the template delimiters of AngularJS thusly:

angular.module('app', [])
  .config(['$interpolateProvider', function ($interpolateProvider) {
    $interpolateProvider.startSymbol('[[');
    $interpolateProvider.endSymbol(']]');
  }]);
Mark Rajcok

You can configure Angular to use interpolation symbols other than {{}}: https://stackoverflow.com/a/11108407/215945

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!