2 if (typeof (console) === 'undefined') console = { debug: function() {} }; // mock console.debug
4 var database = 'casopisi2010';
6 function Upitnik($resource,$xhr){
8 casopisi: [{naslov:''},{naslov:''},{naslov:''}],
11 this.Upitnik = $resource( '/data/:database/Upitnik/:id', { id:'', database: database } );
13 this.$watch('$location.hashPath', this.hash_change);
15 console.debug( 'database', database, this.upitnik );
17 Upitnik.$inject=['$resource','$xhr'];
20 hash_change: function() {
21 var id = this.$location.hashPath;
22 console.debug( 'hash_change', id, this.upitnik.$id );
23 if ( id != this.upitnik.$id ) {
26 this.Upitnik.get({ id: id }, function(upitnik) {
27 console.debug('upitnik', id, upitnik);
28 self.last_saved = angular.copy(upitnik);
29 self.upitnik = upitnik; // needed for load_symposium below
36 console.debug( this.Upitnik );
37 this.upitnik = new this.Upitnik( this.master );
38 console.debug( 'reset', this.upitnik );
39 this.last_saved = this.upitnik;
43 this.upitnik.$save(function(upitnik){
44 self.$location.hashPath = upitnik.$id;
45 self.last_saved = angular.copy(upitnik);