gpt4 book ai didi

javascript - Angular : assigning ng-options dynamically, 奇怪的行为

转载 作者:行者123 更新时间:2023-11-28 08:44:21 25 4
gpt4 key购买 nike

我正在构建一个内联可编辑表单。

我的指令将 ng-options 传递给模板。 Jade 文件:

div(input-inline-select="myobj.val" options="c.name for c in codes" tabindex="1")

在指令中:

scope.options = attr.options;

在模板渲染中选择:

div(class="input_inline_edit_div")
{{options}}
select(class="inline_edit_select" ng-options="{{options}}" ng-model="model" on-enter="save()" on-esc="cancel()" ng-show="editMode" tabindex="{{tabindex}}" ng-focus="edit()")
span(ng-mouseenter="showEdit = true" ng-mouseleave="showEdit = false")
span(ng-hide="editMode" ng-click="edit()" )
div(class="inline_edit_text")
{{model}}

发生的情况是,第一个 {{options}} 正确打印了代码中的 c.name for c,但是 ng-options="处的那个{{options}}" 没有,并且代码实际上已损坏并且没有可见的选项。知道为什么吗?为什么选项可以正确地“自己”扩展而不是作为属性值?

最佳答案

删除{{}}

ng-options="options"

关于javascript - Angular : assigning ng-options dynamically, 奇怪的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20060436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com