JSFiddle - React, Tailwind, and code Playground
by Evan Sharp
HTML
<div ng-app="myApp">
<div ng-controller="ctrl1">
<input type="text" ng-model="isLoggedIn" />
<input type="button" id="btnChangeIsLoggedIn" value="change logged in" ng-click="change()" />
</div>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
myApp.service('authService', function () {
this.isLoggedIn = false;
});
myApp.controller('ctrl1', function ($scope, authService) {
$scope.isLoggedIn = authService.isLoggedIn;
$scope.$watch(function(){return authService.isLoggedIn;}, function (newValue) {
alert("isLoggedIn changed to " + newValue);
}, true);
$scope.change = function() {
authService.isLoggedIn = true;
};
});