Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body ng-app="test">
  <div ng-controller="Test1">
    <button type="button" ng-click="modify()">Change!</button>
  </div>
    
  <div ng-controller="Test2">
    param1: {{serv.param1}}<br>
    param2: {{serv.param2}}
  </div>
</body>
</html>
 
angular.module('test', [])
.controller("Test1", function($scope, Serv){
  $scope.serv = Serv.data;
  
  $scope.modify = function(){
    $scope.serv.param1 = Math.random()*100;
    $scope.serv.param2 = Math.random()*100;
  }
})
.controller("Test2", function($scope, Serv){
  $scope.serv = Serv.data;
})
.factory("Serv", function(){
  var data = {
    param1: '',
    param2: ''
  }
  
  return {
    data: data
  }
});
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers