I'm have a button that will change the underlying $scope and it can show it changes but the text in the mapped/bound div doesn't change
to specify my desired result is when I click the button with the text button it should change the text of <div id="text"> how ever it doesn't so I'm not sure what I'm doing incorrectly
var myApp = angular.module('myApp', []);
myApp.controller('myCtrl', function($scope){
$scope.data =
{"person":
{"id": 3,
"text": "this is the text value"
}
};
});
setTimeout(function(){
var elem = document.getElementById('ex');
elem.addEventListener('click',
function(){
$scope = angular.element(document.getElementById('text')).scope();
$scope.data.person.text = "this is new text";
},false);
elem = document.getElementById('log');
elem.addEventListener('click', function(){
console.log(angular.element(document.getElementById('text')).scope().data.person.text);
},false)
//alert('load');
},500);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<div id="id" ng-model="data.person.id">{{data.person.id}}</div>
<div id="text" ng-model="data.person.text">{{data.person.text}}</div>
</div>
<button id="ex">
button
</button>
<button id="log">
log
</button>
div