我正在使用angular和ui-router。虽然我对$ parent和parent-child controller概念有足够的了解,但我无法识别$ parent的这个问题。
我拥有的是,
<div ng-app="myAPP" ng-controller="appCtrl">
<input type="text" ng-model="searchText"/> {{searchText}}
// *******one of ui-view called at appropriate time ******
<div ng-controller="cardCtrl">
{{searchText}} {{$parent.searchText}}
// parent child scenario.
// I know if I type anything in textbox, I'll get updated value in childCtrl
</div>
// **************
</div>
这很好用。
但问题是我有一个大项目,我无法弄清楚为什么$ parent不能使用相同的场景。我想通过任何工具或其他东西来识别问题区域。
问题是(我的大项目的情况相同),
<div ng-app="myAPP" ng-controller="appCtrl">
<input type="text" ng-model="searchText"/> {{searchText}}
<div ng-controller="cardCtrl">
{{searchText}} {{$parent.searchText}}
// parent child scenario.
// I know if I type anything in textbox, I'll get updated value in childCtrl
</div>
</div>
appCtrl.js
app.controllers("appCtrl",function($scope){
$scope.searchText="HELLO";
// if I write this line then I get HELLO in cardCtrl
// but when I update value through textBox, I dont get updated value at all rather value remain unchanged which is HELLO.
})
cardCtrl.js
app.controllers("appCtrl",function($scope){
})
如果我用小提琴实现同样的东西,我会得到我正在寻找的确切答案。但凭借我的项目,我无法搞清楚。它不可能在这里显示该项目的片段。 有没有人可以提供帮助?
注意:我有一个全局搜索和不同的ui-views。我想在父页面中显示全局搜索,但希望以页面方式实现搜索功能,例如。对于当前页面。 但无论如何都没有得到更新的价值。