奇怪的单向的角UI模态结合 [英] Strange one-way binding in Angular-UI Modal

查看:131
本文介绍了奇怪的单向的角UI模态结合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个角度-UI-引导模态中一个奇怪的一种方式绑定行为。

I am running into a strange one way binding behavior within a Angular-UI-Bootstrap Modal.

在一个HTML模式,二日数据绑定似乎工作正常,但在控制范围内变量模型并没有出于某种原因更新。

Inside a modal html, two day data binding seems to work fine but the scope variable model at the controller does not update for some reason.

如果,然而,范围变量是一个对象,则这两个方式结合似乎传播到控制器。

If, however, the scope variable is an object, then the two way binding seems to propagate to the controller.

有谁知道为什么发生这种情况?反正解决?

Does anyone know why this is happening? Anyway to fix it?

我已经做了plunker来演示该问题。

I have made a plunker to demonstrate the problem.

一种方式模态问题

推荐答案

这似乎是最常见的问题,我看到有棱角的人; 嵌套的范围即可。看看下面的资源: http://jimhoskins.com /2012/12/14/nested-scopes-in-angularjs.html

This seems to be the most common problem I see people having with angular; nested scopes. Have a look at the following resource: http://jimhoskins.com/2012/12/14/nested-scopes-in-angularjs.html

这基本上可以归结为以下几点。如果您尝试访问 $ scope.someVal ,角将搜索父级链寻找 someVal ,如果发现将它退还给您。如果你试图改变 someVal ,将只需创建一个新的 someVal 当前作用域。

This essentially boils down to the following. If you attempt to access $scope.someVal, angular will search up the parent chain looking for someVal, and if found will return it to you. If you try and change someVal, it will simply create a new someVal to the current scope.

然而,如果你试图访问 $ scope.someObj.someVal ,阅读行为以同样的方式。除非你试图改变 someVal 这个时候,它会改变 someObj中,无论哪个范围指挥里面的值该更新。

If however you attempt to access $scope.someObj.someVal, reading acts the same way. Except this time if you try to change someVal, it will change the value inside someObj, no matter which scope is commanding the update.

这篇关于奇怪的单向的角UI模态结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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