Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. 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 🙂