Angular: Empty Fiddle

http://angularjs.org/

by KevinIsNowOnline

HTML

<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
  Hello, {{name}}!
    <button ng-click="changeName()">Change Name</button>
</div>

JavaScript

var myApp = angular.module('myApp',[]);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

myApp.controller("MyCtrl", function($scope, MyService){
     $scope.name = MyService.name;
    
    $scope.changeName = function(){
        debugger;
        MyService.changeName("ash");
    }
});


myApp.service("MyService", function(){
    this.name = "kevin";
    
    this.getName = function(){
     return name;   
    }
    
    this.changeName = function(newName){
        debugger;
        name = newName;
    };
    
    
  });