JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="mapp">
<div ng-controller="ctrl">
<custom-element info="a"></custom-element>
<custom-element info="b"></custom-element>
<br/>
<br/>Total: <span>{{total}}</span>
</div>
</div>
JavaScript
angular.module('mapp', [])
.controller('ctrl', ['$scope', function ($scope) {
$scope.total = 0;
$scope.a = 0;
$scope.b = 0;
$scope.$watchCollection('[a,b]', function () {
console.log('watch');
$scope.total = $scope.a + $scope.b;
});
}])
.directive('customElement', function () {
return {
restrict: 'E',
scope: {
data: '=info'
},
template: '<input type="number" ng-model="data">\
<span>{{data}}</span>'
}
});