JSFiddle - React, Tailwind, and code Playground
by akashivskyy
HTML
<div ng-app="app">
<div ng-controller="first">
<h3>first</h3>
{{ data1 }}
</div>
<div ng-controller="second">
<h3>second</h3>
{{ data2 }}<br /><input type="text" ng-model="data2" />
</div>
</div>
JavaScript
var app = angular.module("app", []);
app.factory("sharedScope", function($rootScope) {
var scope = $rootScope.$new(true);
scope.data = "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;
});