javascript - Angular 数据绑定(bind)不适用于 Jade

标签 javascript angularjs node.js express pug

我编写此测试代码只是为了检查 Angular 是否可以与 Jade 配合使用。

布局.jade

doctype html
html
  head
    title #{title}
    link(rel='stylesheet', href='/stylesheets/style.css')
  body(ng-app='app')
    block content
    script(type="javascript" src="/vendor/bower/angular/angular.min.js")
    script(type="javascript" src="/public/app/module.js")

index.jade

extends layout
block content
  div(ng-controller="mainCtrl")
      h1 #{title}
        input(type="text" ng-model="something")
        | {{something}}

但是 {{something}} 始终显示为字符串而不是占位符。

这个问题已经被问过很多次了,我已经检查过答案但无法解决。

已解决: 这对初学者应该有用

事实证明我没有正确指定文件,

doctype html
html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
    script(type="text/javascript" src="/bower/angular/angular.min.js")
    script(type="text/javascript" src="/javascripts/app/module.js")
  body(ng-app="app")
    block content

作为静态资源的目录,

app.use(express.static(path.join(__dirname, 'public')));

已在 Express 应用程序中定义。

此外,我必须在 app.js (express) 中为“vendor ”添加另一个中间件,即,

app.use(express.static(path.join(__dirname, ' vendor ')));

最佳答案

尝试这样的事情:

extends layout
block content
  div(ng-controller="mainCtrl")
      h1 #{title}
        input(type="text" ng-model="something")
          span(ng-bind="something")

关于javascript - Angular 数据绑定(bind)不适用于 Jade,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31225448/

相关文章:

javascript - 从编码的 Base64 Canvas 下载图像会出现 maxUrlLength 值错误

php - 级联下拉框

javascript - AngularJs:如何在不同域上设置相同的cookie

angularjs - Angular ui.grid 无限滚动不会被第二次调用 onwords

java - 将带有证书和 key 的 NodeJS 请求转换为 Java

node.js - 安装 Angular-cli

javascript - 自动完成完成后隐藏输入字段

javascript - 在这种情况下,为什么我必须单击两次才能加载图像?

javascript - 如何从 getElementById 搜索中获取ElementById?

javascript - $http.get 来自 2 个 jsons Angular