如何在 Angular 上注入不是来自 ngCordova 的离子插件
How to inject on Angular an ionic plugin that is not from ngCordova
我想在我的离子应用程序中使用 cordova-plugin-video-editor plugin,但我不知道如何将它注入我的控制器。
我是这样在终端添加插件的:
ionic plugin add https://github.com/jbavari/cordova-plugin-video-editor.git
并且像这样注入控制器(最后一个):
.controller('VideoCtrl', ['$scope', '$ionicPlatform', '$ionicModal', '$cordovaDialogs', '$cordovaCapture', '$cordovaFileTransfer', '$sce', 'VideoService', '$q', '$http', '$ionicScrollDelegate', '$timeout', '$location', 'VideoEditor', function ($scope, $ionicPlatform, $ionicModal, $cordovaDialogs, $cordovaCapture, $cordovaFileTransfer, $sce, VideoService, $q, $http, $ionicScrollDelegate, $timeout, $location, VideoEditor) {
我收到这个错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to:
Error: [$injector:modulerr] Failed to instantiate module starter.controllers due to:
Error: [$injector:modulerr] Failed to instantiate module VideoEditor due to:
Error: [$injector:nomod] Module 'VideoEditor' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
我很困惑,我正在使用更多插件,但都是 official 而且我没有遇到问题,因为我只需要这样做:
angular.module('starter.controllers', ['ngCordova'])
并且在 html
<script src="lib/ngCordova/dist/ng-cordova.js"></script>
在插件文件夹中有一个 js 文件包含:
var exec = require('cordova/exec'),
pluginName = 'VideoEditor';
function VideoEditor() {
}
VideoEditor.prototype.transcodeVideo = function(success, error, options) {
exec(success, error, pluginName, 'transcodeVideo', [options]);
};
VideoEditor.prototype.createThumbnail = function(success, error, options) {
exec(success, error, pluginName, 'createThumbnail', [options]);
};
module.exports = new VideoEditor();
当我安装插件时,这个 js 内容不应该已经在我的 www 文件夹中的某个地方,所以我可以从 html 导入吗?
删除控制器配置中的 VideoEditor
模块。因为这个VideoEditor
和angular没有任何关系。
您还需要参考 github document。他们就像 jquery 插件一样使用它。不是 angular 插件。有意义吗?如果没有,请告诉我。
如何在 Angular 控制器中实现它?
您可以像 javascript
库一样使用它。
我想在我的离子应用程序中使用 cordova-plugin-video-editor plugin,但我不知道如何将它注入我的控制器。
我是这样在终端添加插件的:
ionic plugin add https://github.com/jbavari/cordova-plugin-video-editor.git
并且像这样注入控制器(最后一个):
.controller('VideoCtrl', ['$scope', '$ionicPlatform', '$ionicModal', '$cordovaDialogs', '$cordovaCapture', '$cordovaFileTransfer', '$sce', 'VideoService', '$q', '$http', '$ionicScrollDelegate', '$timeout', '$location', 'VideoEditor', function ($scope, $ionicPlatform, $ionicModal, $cordovaDialogs, $cordovaCapture, $cordovaFileTransfer, $sce, VideoService, $q, $http, $ionicScrollDelegate, $timeout, $location, VideoEditor) {
我收到这个错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to:
Error: [$injector:modulerr] Failed to instantiate module starter.controllers due to:
Error: [$injector:modulerr] Failed to instantiate module VideoEditor due to:
Error: [$injector:nomod] Module 'VideoEditor' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
我很困惑,我正在使用更多插件,但都是 official 而且我没有遇到问题,因为我只需要这样做:
angular.module('starter.controllers', ['ngCordova'])
并且在 html
<script src="lib/ngCordova/dist/ng-cordova.js"></script>
在插件文件夹中有一个 js 文件包含:
var exec = require('cordova/exec'),
pluginName = 'VideoEditor';
function VideoEditor() {
}
VideoEditor.prototype.transcodeVideo = function(success, error, options) {
exec(success, error, pluginName, 'transcodeVideo', [options]);
};
VideoEditor.prototype.createThumbnail = function(success, error, options) {
exec(success, error, pluginName, 'createThumbnail', [options]);
};
module.exports = new VideoEditor();
当我安装插件时,这个 js 内容不应该已经在我的 www 文件夹中的某个地方,所以我可以从 html 导入吗?
删除控制器配置中的 VideoEditor
模块。因为这个VideoEditor
和angular没有任何关系。
您还需要参考 github document。他们就像 jquery 插件一样使用它。不是 angular 插件。有意义吗?如果没有,请告诉我。
如何在 Angular 控制器中实现它?
您可以像 javascript
库一样使用它。