No edit summary |
(Automatically adding template at the end of the page.) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 8: | Line 8: | ||
===== An Example with Delayed Calling of Functions ===== | ===== An Example with Delayed Calling of Functions ===== | ||
For example, using this in an | 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 | 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())" | 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 | 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> | <script> | ||
function DelayedSave(scope) { | function DelayedSave(scope) { | ||
Line 25: | Line 25: | ||
[[Category:MDriven Turnkey]] | [[Category:MDriven Turnkey]] | ||
[[Category:View Model]] | [[Category:View Model]] | ||
{{Edited|July|12|2024}} |
Latest revision as of 15:49, 10 February 2024
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.