Created
May 1, 2013 18:11
-
-
Save mgonto/5497061 to your computer and use it in GitHub Desktop.
Model Service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module("test").service("Greeting", function() { | |
| this.greet = null; | |
| this.greetTo = function(name) { | |
| this.greet = "Hello " + name; | |
| } | |
| }); | |
| angular.module("test").controller("TestCtrl", function(Greeting) { | |
| $scope.greeting = Greeting; | |
| $scope.$watch("greeting", function(){ | |
| // The model has changed. Do something | |
| }); | |
| $scope.greeting.greetTo("Gonto"); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment