使用防爆preSS把手和角度JS [英] Using Express Handlebars and Angular JS

查看:117
本文介绍了使用防爆preSS把手和角度JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在建设一个使用 的NodeJS为服务器网站的防爆preSS把手(只是把手但服务器端),并希望 AngularJS 一些客户端的东西。

I am currently building a website that uses NodeJS for the server, Express Handlebars(Just Handlebars but server side) , and hopefully AngularJS for some client side stuff.

结果

AngularJS和把手使用相同的语法为模板结果
{{}富} 结果
这导致了一个问题,AngularJS code会间$ P $最早由前preSS把手PTED,然后将抛出一个错误,因为它试图拉数据只在角没有节点存在。

AngularJS and Handlebars use the same syntax for templating
{{foo}}
This causes a problem where AngularJS code will be interpreted by Express Handlebars first, which will then throw an error because the data it is trying to pull only exists in Angular not Node.

结果

有没有办法让AngularJS和Ex preSS把手一起工作?

Is there a way to get AngularJS and Express Handlebars to work together?

结果


  • 更改AngularJS的语法

    • 我看着BackboneJS,它看起来是可以改变的语法。有可能可能是类似的东西是AngularJS。


    • 这将只返回其​​未解析的内容。不过,我无法弄清楚如何做到这一点。

    推荐答案

    您第一个解决方案是可行的,AngularJS允许更改文本插值的开始/结束符号是这样的:

    Your first solution is possible, AngularJS allow to change the start/end symbols of text interpolation like this:

    appModule.config(function($interpolateProvider) {
      $interpolateProvider.startSymbol('{[{');
      $interpolateProvider.endSymbol('}]}');
    });
    

    然后,你可以在你的模板中使用它:

    Then you could use it in your template:

    <div>{[{message}]}</div>
    

    另请参阅: $ interpolateProvider文档

    希望这有助于。

    这篇关于使用防爆preSS把手和角度JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆