KnockoutJS在AngularJS中的“与”绑定?
发布时间:2020-12-17 08:08:30 所属栏目:安全 来源:网络整理
导读:我刚从KnockoutJS切换到AngularJS,我无法在AngularJS中找到KnockoutJS的“with”数据绑定。 这是KnockoutJS中的一段代码。 “with”绑定创建一个新的绑定上下文,以便后代元素在指定对象的上下文中绑定。 h1 data-bind="text: city" /h1p data-bind="with:
我刚从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> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |