【发布时间】:2015-07-01 21:46:37
【问题描述】:
我在我的nodejs项目中使用ejs模板引擎,我通过下面的代码输出了文本元素
<%- text_field_tag('empId', '', {id: 'empId', Class: 'some_class', type: 'text'}) %>
现在为了使用 AngularJs 的优势,我想添加 ng-model 属性,所以我修改了如下代码
<%- text_field_tag('empId', '', {id: 'empId', Class: 'some_class', type: 'text', ng-model: "empId"}) %>
但这以错误结束——如下所示
SyntaxError: Unexpected token - in /home/ubuntu/workspace/public/views/add.ejs while compiling ejs
让我知道我应该如何实现这一目标?
【问题讨论】:
-
@AntoineEsteve 答案是正确的。使用
'ng-model': 'empId'。 -
我认为 AntoineEsteve 删除了他的答案,但那不起作用
-
查看您对@AntoineEsteve 的评论,您使用
'ng-model'='empId'而不是'ng-model':'empId'。 -
是的,它可以工作——我的错误是我使用 = 而不是:谢谢 Aleksandr。我们能得到那个答案吗?
-
等待 Antoine 取消删除他的回答,如果没有,您可以自行回答。