How can I bind a value between two sibling controllers, child1.controller.ts and child2.controller.ts?
/*
file :
index.html
|_app.ts
|_app.confing.ts (routing with parent.html and invoke parent controller)
|
|_parent.controller.ts
parent.html
|__ (invoke child1 Directive)
| |_child1.contoller.ts
| |_child1.html
|
|__(invoce child2 Directive)
|_child2.contoller.ts
|_child2.html
parent.html
<child1-tab></child1-tab>
<child2-tab></child2-tab>
*/
Code snippet from parent.controller.ts:
module app.parent{
'use strict';
class ParentController {
static $inject = ["$scope"];
constructor(public $scope)
{
scope.status = "Parent Controller";
}
}
}
Code snippet from child1.controller.ts:
/*child1-tab-Controller*/
module app.child1{
class child2Controller {
comingValue :string;
static $inject = ["$scope"];
constructor(public $scope){
this.comingValue = ""; //<= (I want to update it via child2.controller)
}
}
angular.module('myApp')
.controller('child1Controller', child1Controller);
}
Code snippet from child2.controller.ts:
/*child2-tab-Controller*/
module app.child1{
class child2Controller {
newValue:string;
static $inject = ["$scope"];
constructor(public $scope){
this.newValue = "Send It to Child1"; //(newValue be send to child1Controller and set to the comingValue field in child1Controller)
}
}
angular.module('myApp')
.controller('child2Controller', child2Controller);
}
Is there a way to use child2.controller's newValue to set the child1.controller's comingValue?