(attrName)
| 32 | |
| 33 | // This function helps us extract the callback functions from the directive attributes |
| 34 | var makeFn = function(attrName) { |
| 35 | var fn = scope.$eval(attrs[attrName]); |
| 36 | if ( !angular.isFunction(fn) ) { |
| 37 | throw new Error('crudEdit directive: The attribute "' + attrName + '" must evaluate to a function'); |
| 38 | } |
| 39 | return fn; |
| 40 | }; |
| 41 | // Set up callbacks with fallback |
| 42 | // onSave attribute -> onSave scope -> noop |
| 43 | var userOnSave = attrs.onSave ? makeFn('onSave') : ( scope.onSave || angular.noop ); |