Table of Contents

Context (dnn-sxc-angular)

you are here (click to zoom) - discover the stack

dnn-sxc-angular can give you a lot of Context Information like this:

  • what Page the app is on
  • what Module it's on
  • the $2sxc object of the page
  • the sxc object of the current module

...and more

Example

We'll explain how to get one or many items based on the Template App.

Check out the team.service.ts - you'll see some code like this:

@Injectable({ /* ... */ })
export class TeamService {
  private selectedBu$ = new BehaviorSubject<string>('');

  /** This will contain the persons returned from the API */
  team$: Observable<Person[]>;

  constructor(data: Data, context: Context) {
    // also get guid if in edit mode
    const withGuid = context.sxc?.isEditMode() ? '&includeGuid=true': '';
    this.team$ = this.selectedBu$.pipe(switchMap(bu => data.query$<Person[]>(`BusinessUnitTeam?bu=${bu}${withGuid}`)));
  }
}

In the above example you'll see these lines:

const withGuid = context.sxc?.isEditMode() ? '&includeGuid=true': '';

Here we're asking the context object for the current sxc instance (of this module) to find out if we're in edit-mode. In this example it will then affect the Query to include more data for the in-page editing experience.

More APIs

The Context has more to offer - just check out the intellisense in VS Code.