I am having problem with $rootScope. I am changing the value in "button" clicked event, but it's NOT changing in the directive.
HTML page shows "TEST" to start with, on button click, I am expecting to change to "CLICKED". What is the mistake? in my code, please help.
<html>
<script src="jquery.min.js"></script>
<script src="angular.js"></script>
<script>
"use strict";
var app = angular.module('myApp', []);
app.run(function ($rootScope) {
$rootScope.name = 'TEST';
});
app.controller('btnCtrl', function($scope, $rootScope){
$("#Btn").click( function($rootScope) {
alert('Btn clicked');
$rootScope.name = 'CLICKED';
});
});
</script>
<body>
<div ng-app="myApp">
<b> {{name}} </b>
<p> Clcik button to change above text to "CLICKED", <u>not working why?</u></p>
<div ng-controller="btnCtrl" >
<input type="button" value="Button" id="Btn" />
</div>
</div>
</body>
</html>