的&QUOT与......;在AngularJS KnockoutJS的约束力? [英] The "with" binding of KnockoutJS in AngularJS?

查看:104
本文介绍了的&QUOT与......;在AngularJS KnockoutJS的约束力?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚从KnockoutJS切换到AngularJS,我不能够找到KnockoutJS的与数据绑定在AngularJS。

I have just switched from KnockoutJS to AngularJS and I am not able to find the KnockoutJS's "with" data-bind in AngularJS.

下面是一块KnockoutJS code的。 有的结合创建了一个新的绑定上下文,以便后代元素在一个指定的对象的上下文中的约束。

Here is the piece of code in KnockoutJS. The "with" binding creates a new binding context, so that descendant elements are bound in the context of a specified object.

<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有这样背景下东西吗?

Does AngularJS have anything like context?

推荐答案

没有像与我知道这的..是我能做的最好的:

Nothing like with that I know of.. this is the best I could do:

<h1>{{city}}</h1>
<p ng-repeat="c in [coords.or.possibly.deeper.in.tree]">
    Latitude: {{c.latitude}},
    Longitude: {{c.longitude}}
</p>

这篇关于的&QUOT与......;在AngularJS KnockoutJS的约束力?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆