Created
          February 11, 2012 01:57 
        
      - 
      
- 
        Save vojtajina/1795233 to your computer and use it in GitHub Desktop. 
    Angular: 0.9.19 resource example
  
        
  
    
      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
    
  
  
    
  | )]}', | |
| [{ | |
| "name": "one" | |
| }, { | |
| "name": "two" | |
| }] | 
  
    
      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> | |
| <head> | |
| <script type="text/javascript" src="http://code.angularjs.org/0.9.19/angular-0.9.19.js" ng:autobind></script> | |
| <title></title> | |
| <script type="text/javascript"> | |
| function Ctrl($resource) { | |
| var R = $resource('/tmp/:some'); | |
| this.save = function(resource) { | |
| resource.$save(function() { | |
| console.log('SUCCESS save'); | |
| }, function() { | |
| console.log('ERROR save'); | |
| }); | |
| }; | |
| this.anotherSave = function(resource) { | |
| R.save(resource, function() { | |
| console.log('SUCCESS another save'); | |
| }, function() { | |
| console.log('ERROR another save'); | |
| }); | |
| }; | |
| this.load = function() { | |
| this.items = R.query({some: '12.json'}, function() { | |
| console.log('SUCCESS query'); | |
| }, function() { | |
| console.log('ERROR query'); | |
| }); | |
| }; | |
| } | |
| </script> | |
| </head> | |
| <body ng:controller="Ctrl"> | |
| <a ng:click="load()">LOAD</a> | |
| <div ng:repeat="i in items"> | |
| {{i.name}}: | |
| <a ng:click="save(i)">SAVE</a> | <a ng:click="anotherSave(i)">ANOTHER</a> | |
| </div> | |
| </body> | |
| </html> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment