teaScopeDecorator
This is a service available in the module tea.services. The teaScopeDecorator service decorates the scope with a TeaObject based on the current URL. It also attaches several utility methods that are useful in the teaMasthead directive and elsewhere.
Dependencies
- teaLocation
- teaObjectService
- $q
- $http
- $modal
Methods
Parameters
object {TeaObject} – The object to navigate to.
Parameters
object {TeaObject} – The object to navigate to.
Parameters
object {TeaObject} – The object whose status is to be displayed
Returns
{String} – tea-status-ok or tea-status-error
Parameters
- operationName {String} – Name of the operation
- defaultValues {String[]} – (optional) default values for the operation parameters
- onSuccess {Function} – A function to call upon successful completion of the operation call. By default, scope.reload is called.
- validatorfn {Function(paramName, paramValue)} – (optional) A function which validates the form's parameter values. This function takes two parameters, name and value, to be validated. The function returns an error message in case the validation fails. If the validation passes, it does not return anything.
Parameters
- operationName {String} – Name of the operation
- defaultValues {String[]} – (optional) default values for the operation parameters
- onSuccess {Function} – A function to call upon successful completion of the operation call. By default, scope.reload is called.
Parameters
- object {TeaObject} – The object containing the reference
- refName {String} – The name of the reference
- onReferenceDo {Function} – The function that will be executed as a promise, passed the Array<TeaObject> returned by teaObjectService.getReference
Usage
myModule.controller('MyController', function ($scope, teaScopeDecorator) {
teaScopeDecorator($scope);
// TeaObject now available under $scope.object
// functions $scope.openOperation, $scope.goto, $scope.goToProduct,
// $scope.getReference, and $scope.getStatusClass available
});