【问题标题】:how to use angularjs in clojure luminus如何在 clojure luminus 中使用 angularjs
【发布时间】:2016-11-04 03:46:29
【问题描述】:

我想在 clojure luminus 模板中使用 angularjs。 下面是我在 luminus 中的代码。

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
    <div ng-app="">
      <p>Name : <input type="text" ng-model="name"></p>
      <h1>Hello {{name}}</h1>
    </div>

但没有获得 {{name}} 值。 请帮助我如何解决这个问题。在此先感谢!

【问题讨论】:

  • 我认为它很完美。提供有关您的问题的更多信息。
  • 我没有得到 name 的值,{{name}} 是空的,
  • 批准我的编辑并检查它。
  • 你在 {block} 外运行,但我需要它在 clojure-luminus {block} 内。
  • 如果我做样品。 clojure-lumius 如何区分 luminus 标签和 angularjs 标签。因为两者都使用相同的标签 {{}}..

标签: angularjs clojure luminus


【解决方案1】:

默认情况下,luminus 使用Selmer 模板系统。 Selmer - 为您提供重新定义:tag-open :tag-close :filter-open :filter-close 标签的选项。

所以如果你把你的渲染函数改成这样:

(defn render
  "renders the HTML template located relative to resources/templates"
  [template & [params]]
  (content-type
 (ok
  (parser/render-file
    template
    (assoc params
      :page template
      :csrf-token *anti-forgery-token*
      :servlet-context *app-context*) {:tag-open \[ :tag-close \] :filter-open \[ :filter-close \[}))
"text/html; charset=utf-8"))

您将能够使用角度标签,但您必须将所有塞尔默标签替换为[% %]。 此外,您可以使用任何您想要的作为打开/关闭标签。敌人示例 &lt;&gt;

【讨论】:

    猜你喜欢
    • 2016-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多