Created
May 1, 2012 18:52
-
-
Save mchung/2570456 to your computer and use it in GitHub Desktop.
hello-window
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
<!doctype html> | |
<html ng-app="MyApp"> | |
<script src="http://code.angularjs.org/angular-1.0.0rc7.js"></script> | |
<script type="text/javascript"> | |
var app = angular.module('MyApp', []); | |
app.factory('greeter', function($window) { | |
return { | |
greet: function(text) { | |
$window.alert(text); | |
} | |
} | |
}); | |
app.controller('MainCtrl', ['$scope', 'greeter', function($scope, greeter) { | |
$scope.alert = function(msg) { | |
greeter.greet("Factory Powered Greeter: " + msg); | |
} | |
}]); | |
</script> | |
<body ng-controller="MainCtrl"> | |
<input type="text" ng-init="greeting='Hello World!'" ng-model="greeting" /> | |
<button ng-click="alert(greeting)">ALERT</button> | |
</body> | |
</html> |
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
<!doctype html> | |
<html ng-app="MyApp"> | |
<script src="http://code.angularjs.org/angular-1.0.0rc7.js"></script> | |
<script type="text/javascript"> | |
var app = angular.module('MyApp', []). | |
controller('MainCtrl', ['$scope', '$window', function($scope, $window) { | |
$scope.$window = $window; | |
}]); | |
</script> | |
<body ng-controller="MainCtrl"> | |
<input type="text" ng-init="greeting='Hello World!'" ng-model="greeting" /> | |
<button ng-click="$window.alert(greeting)">ALERT</button> | |
</body> | |
</html> |
Are the angular guys even aware of this ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for creating this. I used the latter and it worked!
Funny how the angular.js example is still broken. Been a year.