View/Page override

You can write your own cshtml to override the built-in page renderer in Turnkey.

Accessing the Angular $scope in Javascipt Code Called Inside a Page

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

angular.element(this).scope()

This will get the scope of the current element from "anywhere"

angular.element($0).scope()
An Example with Delayed Calling of Functions

For example, using this in an on-click 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 an on-click 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 on-click is executed.

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

Read more on how to make on-click work on an angular page: Ng-click ( ngClick ) not working

See also EXT Components for overriding only a ViewModel attribute with your own code.

This page was edited 149 days ago on 06/17/2024. What links here