JSFiddle - React, Tailwind, and code Playground
by hxtpoe
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<div>
<div ng-controller="Controller">
{{user.name}}
</div>
</div>
<button id="emit">emit</button>
JavaScript
angular.element(document).ready(function () {
angular.bootstrap(document, ['App']);
});
angular.module('App', [])
.controller('Controller', ['$document', '$scope', function($document, $scope) {
$scope.user = {'name' : "Hello"};
$document.on('myevent', function() {
$scope.$apply(
function() {
$scope.user.name = "hello my event!";
});
})
}]);
// end of angular/ionic app
var button = document.getElementById("emit");
button.onclick = function() {
var event = new CustomEvent("myevent", {});
document.dispatchEvent(event);
};