phonertc离子演示科尔多瓦未定义

问题描述:

我是ionic的新手,正在尝试在ionic平台上安装phonertc,但是当我运行该应用程序时,它对VideoViewDirective而言显示RefrenceError:cordova未定义.

I am a newbie with ionic and trying to install phonertc on ionic platform but when i run the app it shows for VideoViewDirective that RefrenceError: cordova is undefined.

VideoViewDirective.js

VideoViewDirective.js

angular.module('phonertcdemo')
  .directive('videoView', function ($rootScope, $timeout) {
return {
  restrict: 'E',
  template: '<div class="video-container"></div>',
  replace: true,
  link: function (scope, element, attrs) {
    function updatePosition() {
    cordova.plugins.phonertc.setVideoView({
        container: element[0],
        local: { 
          position: [240, 240],
          size: [50, 50]
        }
      });
    }

    $timeout(updatePosition, 500);
    $rootScope.$on('videoView.updatePosition', updatePosition);
  }
}
});

如果使用离子服务运行,则可能会显示cordova未定义.

If you are running using ionic serve, it is expected to show cordova is undefined.

如果要在浏览器中运行它,则应该

If you want to run it in browser, you should

ionic platform add browser
ionic run browser

然后,您将可以在浏览器中使用cordova的一部分.

Then you will be able to use part of cordova in your browser.