I am trying to accomplish what seems should be a simple task but i'm stumped.
Here is the simplest example I could come up with.
<html lang="en" data-ng-app="myApp">
<head>
<script src="js/angular.js"></script>
<script>
var test = 'Hello World';
var myApp = angular.module("myApp", []);
myApp.controller("myCtrl", function ($scope) {
$scope.testStr = test;
});
myApp.run(function($http){
test = 'scope updates';
$http.get("controllers/getTestStr.jsp").success(function (data) {
//console.log('returned');
test = 'scope does not update';
});
});
</script>
</head>
<body ng-controller="myCtrl" style="padding:10px;">
<p>{{testStr}}</p>
</body>
</html>
Essentially I am initializing a variable called test and binding the variable to the testStr scope. If I update the test variable on run() the testStr updates in the view. But if I update that same variable via a $http.get request then the view never gets updated. Why is this? What is the best way to accomplish this task?
Any enlightenment is greatly appreciated.
Anguar v1.2.16