Skip to content

Commit

Permalink
Afform - use search params instead of route params
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Mar 2, 2021
1 parent ad18a4e commit e51a456
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ext/afform/core/ang/afCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@
angular.module('afCore', CRM.angRequires('afCore'));

// Use `afCoreDirective(string name)` to generate an AngularJS directive.
angular.module('afCore').service('afCoreDirective', function($routeParams, crmApi4, crmStatus, crmUiAlert) {
angular.module('afCore').service('afCoreDirective', function($location, crmApi4, crmStatus, crmUiAlert) {
return function(camelName, meta, d) {
d.restrict = 'E';
d.scope = {};
d.scope.options = '=';
d.link = {
pre: function($scope, $el, $attr) {
$scope.ts = CRM.ts(camelName);
$scope.routeParams = $routeParams;
$scope.meta = meta;
$scope.crmApi4 = crmApi4;
$scope.crmStatus = crmStatus;
$scope.crmUiAlert = crmUiAlert;
$scope.crmUrl = CRM.url;

// Afforms do not use routing, but some forms get input from search params
$scope.$watch(function() {return $location.search();}, function(params) {
$scope.routeParams = params;
});
}
};
return d;
Expand Down

0 comments on commit e51a456

Please sign in to comment.