我是新角度和学习。当我看到这个网址https://stackoverflow.com/a/19177773/6188148的代码时,事情并不清楚。如何从子范围内更新父范围中的模型?
看到代码并告诉我为什么模型数据不能从子范围更新?
<input type="text" ng-model="data">
<div ng-if="true">
<input type="text" ng-model="data">
</div>
再次看到下面的代码,并告诉我有什么特别的东西在那里为父范围内的哪个模型从子范围内更新?
<input type="text" ng-model="data.input">
<div ng-if="true">
<input type="text" ng-model="data.input">
</div>
他们只使用data.input
和父数据从小孩范围更新....这是不明确。 。输入关键字有什么特别之处?
请帮我理解第二个例子如何通过。输入更新父数据?
也告诉我什么时候子范围被创建?当我们使用ng-if或ng-show时呢?
感谢
请参阅本 - 希望这将解决你的疑惑http://stackoverflow.com/questions/14049480/what-are-the-nuances-of-scope-prototypal-prototypical- inheritance-in-angularjs –
您应该阅读[本文](https://teropa.info/blog/2015/10/18/refactoring-angular-apps-to-components.html)并采用组件体系结构,以及其投入产出边界任务。它会立即提高你的角度敏锐度,并使范围混乱成为过去。 – isherwood