我刚从KnockoutJS切换到AngularJS,我无法在AngularJS中找到KnockoutJS的“with”数据绑定。
这是KnockoutJS中的一段代码。 “with”绑定创建一个新的绑定上下文,以便后代元素在指定对象的上下文中绑定。
<h1 data-bind="text: city"> </h1>
<p data-bind="with: coords">
Latitude: <span data-bind="text: latitude"> </span>,Longitude: <span data-bind="text: longitude"> </span>
</p>
<script type="text/javascript">
ko.applyBindings({
city: "London",coords: {
latitude: 51.5001524,longitude: -0.1262362
}
});
</script>
AngularJS有什么情况吗?
没有什么像我知道的..这是我能做的最好的
<h1>{{city}}</h1>
<p ng-repeat="c in [coords.or.possibly.deeper.in.tree]">
Latitude: {{c.latitude}},Longitude: {{c.longitude}}
</p>