I have a video on the main page of my application that plays at startup. When the video ends, I would like to use some CSS 3 transitions to move the page.
<ion-view hide-back-button="true" title=""> <ion-pane> <div class="home-video"> <video autoplay="autoplay" ng-click="ctrl.video()" aria-label="video of IBM logo" tabindex="-1" aria-hidden="true" poster="images/Hero_Final_Placeholder.gif" onended="ctrl.video()"> <source src="videos/video.mp4" type="video/mp4"> <img src="images/video_backup.gif" title="Your browser does not support the video tag."> </video> </div> </ion-pane> </ion-view>
At the end of the video, I would like to be able to call the angularJS Controller function.
'use strict'; angular.module('app', ['ionic']).config(function ($stateProvider, $urlRouterProvider) { $stateProvider.state('home', { url: "/home", templateUrl: 'views/home.html', controller: 'homeCtrl as ctrl' }).state('project', { url: "/project/:projectId", templateUrl: 'views/project.html', controller: 'projectCtrl' });
My controller looks like this:
'use strict'; var app = angular.module('app', false); app.controller('homeCtrl', function ($rootScope){ this.data = {}; var ctrl = this; this.video = function () { console.log("video done"); } });
If I put a console.log() in the <video onended=""> element, it will print it. If I try to call ctrl.video() , which contains the same console.log, I get the following error:
Uncaught ReferenceError: ctrl is not defined
I know that ctrl is defined because if I add ng-click="ctrl.video()" and I click on the video player that it prints.