Angular: force angular rerender
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.0rc8.js"></script>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<div ng-controller="MyCtrl">
<div>{{message}}</div>
<button ng-click="login()">Login</button>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
function MyCtrl($rootScope, $scope) {
if($rootScope.user) { // logged
$scope.message = $http(...); // read some content from server
} else {
$scope.message = $http(...); // read some other content from server
}
$scope.login = function() {
$rootScope.user = $http(...); // try login
}
}