When I click a button in myCtrl controller. The ng-model of myCtrl2 should also be changed with ng-model of current controller:
<div ng-app="myApp" >
<div ng-controller="myCtrl">
<input type="text" ng-model="name">
<button ng-click="just()">submit</button>
</div>
<div ng-controller="myCtrl2">
<input type="text" ng-model="name2">
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.name="before";
$scope.just = function()
{
$scope.name="after";
$scope.name2="after"; ///// this is not working
}
});
</script>