Created
March 21, 2011 19:58
-
-
Save arantius/880088 to your computer and use it in GitHub Desktop.
angular .save() / .get() confusion test case
This file contains 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
application: angular-resource-save-test | |
version: 1 | |
runtime: python | |
api_version: 1 | |
handlers: | |
- url: / | |
static_files: index.html | |
upload: index.html | |
- url: /foo.json | |
static_files: foo.json | |
upload: foo.json |
This file contains 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
{"name": "bar", "obj": {"value": 42}} |
This file contains 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 xmlns:ng="http://angularjs.org"> | |
<head> | |
<title>Angular Save Resource Test</title> | |
</head> | |
<body> | |
<div ng:controller="FooCtrl"> | |
<input type="text" name="foo.name"><br> | |
obj.value: <input type="text" name="foo.obj.value"><br> | |
<button ng:click="save()">Save</button> | |
<pre>foo: {{foo}}</pre> | |
<pre>obj: {{obj}}</pre> | |
</div> | |
<script src="http://code.angularjs.org/angular-0.9.13.min.js" ng:autobind></script> | |
<script type="text/javascript"> | |
function FooCtrl($resource) { | |
this.Foo = $resource('./foo.json'); | |
this.foo = {}; | |
this.Foo.get(angular.bind(this, this.loadFooCallback)); | |
} | |
FooCtrl.$inject = ['$resource']; | |
FooCtrl.prototype.loadFooCallback = function(foo) { | |
this.foo = foo; | |
this.obj = foo.obj; | |
this.obj.value = -1; | |
} | |
FooCtrl.prototype.save = function() { | |
this.foo.$save(); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment