JSFiddle - React, Tailwind, and code Playground
by Simone D'Avico
HTML
<div ng-app="app">
<div ng-controller="first">
<h3>first</h3>
{{ data1.text }}
</div>
<div ng-controller="second">
<h3>second</h3>
{{ data2.text }}<br /><input type="text" ng-model="data2.text" />
</div>
</div>
JavaScript
var app = angular.module("app", []);
app.factory("sharedScope", function($rootScope) {
var scope = $rootScope.$new(true);
scope.data = {text: "init text from factory"};
return scope;
});
app.controller("first", function($scope, sharedScope) {
$scope.data1 = sharedScope.data;
});
app.controller("second", function($scope, sharedScope) {
$scope.data2 = sharedScope.data;
});