test stupid angular

by SkeLLLa

HTML

<body ng-app="app">
  <div ng-contorller="ctrl">
    <span>sdfsadf {{svc.a}}</span>
    <a ng-click="test()">test</a>
  </div>
</body>

JavaScript

angular.module('app', [])
  .service('testSvc', ['$rootScope', function($rootScope) {
    this.a = 1;
    this.test = function() {
    		console.log(123);
      $rootScope.$applyAsync(function(){
      	this.a = 2;
      })
    }
  }])
  .controller('ctrl', ['$scope', 'testSvc', function($scope, testSvc) {
  	$scope.svc = testSvc;
    $scope.test = function() {
    	console.log(222);
      testSvc.test();
    }
  }])