Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
I will call a service automatically when a view is loaded. I try this via window.onload or document.onload but this will not work. How can I realized this?
Solved! Go to Solution.
Yes, I'm sure, I use it all the time. But you have to define the function first before assigning it as a callback. So try this instead:
$scope.init = function(){ console.log("bla"); }; angular.element(document).ready($scope.init);
You can do this by adding something like this to each View's JS pane:
angular.element(document).ready($scope.storeInitialState);
Replace "$scope.storeInitialState" with the name of your function, and it should fire when the view is done loading.
I add this to my code:
angular.element(document).ready($scope.init); $scope.init = function(){ console.log("bla"); };
and I get this in my console logs:
TypeError: a is not a function
Are your sure I can use angular stuff in TWX Studio?
try this .....
angular.element(document).ready(function () {
$scope.init();
});
$scope.init = function(){ console.log("bla"); };
I hope to be proved helpful.
bye
Giuseppe
Yes, I'm sure, I use it all the time. But you have to define the function first before assigning it as a callback. So try this instead:
$scope.init = function(){ console.log("bla"); }; angular.element(document).ready($scope.init);
Thx that works 🙂