{{data}}
Well, seems that this is not the first question about this subject, but...
I know that we can use service or events for this, but there are many posts on the interne
One way is using scope inheritance:
angular.module('app', [])
.run(['$rootScope', function($rootScope){
$rootScope.sharedObj = {search:''};
}])
.controller('navCtr',['$scope',function($scope){
}])
.controller('routeCtr',['$scope',function($scope){
$scope.$watch("sharedObj.search",function(d){
$scope.data = d ? 'Searched data is ' + d : '';
});
}]);
.main div{
display:inline-block;
border:1px solid black;
height:100px;
vertical-align: top;
}
.navigation{
width: 20%
}
.navigation input{
max-width: 70%;
}
.page {
width: 75%
}
{{data}}
the second way would be a shared service:
angular.module('app', [])
.factory('srcObject',[function(){
return {
value: ''
}
}])
.controller('navCtr',['$scope', 'srcObject', function($scope, srcObject){
$scope.search = srcObject;
}])
.controller('routeCtr',['$scope', 'srcObject', function($scope, srcObject){
$scope.$watch(function(){return srcObject.value},function(d){
$scope.data = d ? 'Searched data is ' + d : '';
});
}]);
.main div{
display:inline-block;
border:1px solid black;
height:100px;
vertical-align: top;
}
.navigation{
width: 20%
}
.navigation input{
max-width: 70%;
}
.page {
width: 75%
}
{{data}}