- element = $compile('<form name="myForm" crm-autosave="fakeCtrl.doSaveSlowly()" crm-autosave-model="model" crm-autosave-interval="{poll: 25, save: 50}"><input class="fieldA" ng-model="model.fieldA"><input class="fieldB" ng-model="model.fieldB"></form>')($rootScope);
+ var myAutosave = $rootScope.myAutosave = new CrmAutosaveCtrl({
+ save: fakeCtrl.doSaveSlowly,
+ model: function(){ return model; },
+ interval: {poll: 25, save: 50},
+ form: function(){ return $rootScope.myForm; }
+ });
+ myAutosave.start();
+ $rootScope.$on('$destroy', myAutosave.stop);
+ element = $compile('<form name="myForm"><input class="fieldA" ng-model="model.fieldA"><input class="fieldB" ng-model="model.fieldB"></form>')($rootScope);