Html 通过NGM模型传递插值值 {{stepname}}
我想使用ngModel传递stepname(我可以使用插值在前端显示) 但它不起作用Html 通过NGM模型传递插值值 {{stepname}},html,angular,Html,Angular,我想使用ngModel传递stepname(我可以使用插值在前端显示) 但它不起作用 由于stepname在UI中呈现,您可以像下面这样直接将其传递给ngModel- <input [(ngModel)]="newVariablesAttribute.Steps" class="form-control" type="text" readonly name="{{newVariablesAttribute.Steps}}"> {{stepname}} {{stepname}
由于stepname在UI中呈现,您可以像下面这样直接将其传递给ngModel-
<input [(ngModel)]="newVariablesAttribute.Steps"
class="form-control"
type="text" readonly
name="{{newVariablesAttribute.Steps}}">
{{stepname}}
{{stepname}}
(我猜是newVariablesAttribute。步骤是一些对象数组。)没有发现您的代码有任何问题。步骤可能未定义 组件
<input [(ngModel)]="stepname"
class="form-control"
type="text" readonly
name="{{newVariablesAttribute.Steps}}">
{{stepname}}
html:
export class SomeComponent {
newVariablesAttribute = {
Steps: 'step'
};
stepname = 'abc';
}
{{stepname}
O/p
您是否尝试了
[(ngModel)]=“stepname”
(),以及浏览器控制台中的任何错误。正确发布您的代码。它不会工作,因为此ngModel有许多属性,我正在将其直接传递到数据库,{{stepname}即使它是对象数组,它仍会在文本框中显示[object,object]
<input [(ngModel)]="newVariablesAttribute.Steps" class="form-control" type="text" readonly name="{{newVariablesAttribute.Steps}}">{{stepname}}