i wanna call a function when the app starts to show a modal, so i did ...
I call the function with the onDeviceReady
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
openModal();
}
but the function is not calling, in console shows: Uncaught ReferenceError: openModal is not defined
The function on controller:
$scope.openModal = function() {
alert("funcionou!");
$scope.modal.show();
};
please help!
Your code does not know your scope.
You can run it when the controller is loaded.
Like this:
angular.module("controllers",[])
.controller("testController",
function ($scope) {
$scope.$on('$viewContentLoaded',
function () {
$scope.modal.show()
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.