View/Page override
This page was created by Lars.olofsson@mdriven.net on 2022-04-26. Last edited by Stephanie@mdriven.net on 2025-01-23.

You can write your on cshtml to override the built in page renderer of Turnkey.

Accessing the angular $scope in javascipt code called from inside a page

If used in an element, this code gets the current scope.

angular.element(this).scope()

From "anywhere" this will get the scope of the current element

angular.element($0).scope()
Example with delayed calling of functions

For example, using this in an onclick event (NOT ng-click) will call the function DelayedSave in the script tag of the overridden page.

Note that a button can have both an ng-click and a onclick defined and both will be called.

onclick="DelayedSave(angular.element(this).scope())"

This example calls an action in the ViewModel called LazySave to save changes 2 seconds after the action with the onclick is executed.

<script>
  function DelayedSave(scope) {
  setTimeout(function () {
      scope.StreamingViewModelClient.CallServerAction('JournalSeeker', 'LazySave');
    }, 2000);
  };
</script>

More reading on how to make on-click work in an angular page

Ng-click ( ngClick ) not working

Se also EXT Components for overriding only a viewmodel attribute with your own code.