Angular2值单向绑定

时间:2018-07-02 15:38:11

标签: angular typescript data-binding

在Angular中,当我在输入元素中写入新的英雄名称(值)时,如何更改英雄名称​​(第一个div /我想要一个修复名称)不变?

<div>I want a fix name: {{hero.name}}</div>
<div>
  <label>name:
    <input [(ngModel)]="hero.name" placeholder="name">
  </label>
</div>

我相信“技术”被称为单向绑定,但是我似乎没有找到如何实现这种精确方案的方法。

1 个答案:

答案 0 :(得分:2)

使用<input [ngModel]="hero.name" placeholder="name"> 进行单向绑定

# the edges of the graph with corresponding properties
edges = [[x_0, y_0, p_0],
         [x_1, y_1, p_1],
         ...
         [x_n, y_n, p_n]]

# creating an external property
any_property_name = g.new_edge_property("int")

# adding list of all properties 
eprops = [any_property_name]

# add edges and properties to the graph
g.add_add_list(edges, eprops=eprops)