我正在尝试使用最简单的MediaCapture形式用于Ionic 2.我创建了一个全新的项目并按照here添加它。
但是当我尝试使用它时:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { MediaCapture, MediaFile, CaptureError, CaptureImageOptions } from '@ionic-native/media-capture';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(private mediaCapture: MediaCapture) {
}
}
出现此错误(最后是我的环境信息):
Runtime Error
Uncaught (in promise): Error: No provider for MediaCapture! Error at g (http://127.0.0.1:8100/build/polyfills.js:3:7133) at injectionError (http://127.0.0.1:8100/build/main.js:1511:86) at noProviderError (http://127.0.0.1:8100/build/main.js:1549:12) at ReflectiveInjector_._throwOrNull (http://127.0.0.1:8100/build/main.js:3051:19) at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:8100/build/main.js:3090:25) at ReflectiveInjector_._getByKey (http://127.0.0.1:8100/build/main.js:3022:25) at ReflectiveInjector_.get (http://127.0.0.1:8100/build/main.js:2891:21) at AppModuleInjector.NgModuleInjector.get (http://127.0.0.1:8100/build/main.js:3856:52) at resolveDep (http://127.0.0.1:8100/build/main.js:11260:45) at createClass (http://127.0.0.1:8100/build/main.js:11117:35) at createDirectiveInstance (http://127.0.0.1:8100/build/main.js:10954:37) at createViewNodes (http://127.0.0.1:8100/build/main.js:12303:49) at createRootView (http://127.0.0.1:8100/build/main.js:12208:5) at callWithDebugContext (http://127.0.0.1:8100/build/main.js:13339:42) at Object.debugCreateRootView [as createRootView] (http://127.0.0.1:8100/build/main.js:12800:12)
Stack
Error: Uncaught (in promise): Error: No provider for MediaCapture!
Error
at g (http://127.0.0.1:8100/build/polyfills.js:3:7133)
at injectionError (http://127.0.0.1:8100/build/main.js:1511:86)
at noProviderError (http://127.0.0.1:8100/build/main.js:1549:12)
at ReflectiveInjector_._throwOrNull (http://127.0.0.1:8100/build/main.js:3051:19)
at ReflectiveInjector_._getByKeyDefault (http://127.0.0.1:8100/build/main.js:3090:25)
at ReflectiveInjector_._getByKey (http://127.0.0.1:8100/build/main.js:3022:25)
at ReflectiveInjector_.get (http://127.0.0.1:8100/build/main.js:2891:21)
at AppModuleInjector.NgModuleInjector.get (http://127.0.0.1:8100/build/main.js:3856:52)
at resolveDep (http://127.0.0.1:8100/build/main.js:11260:45)
at createClass (http://127.0.0.1:8100/build/main.js:11117:35)
at createDirectiveInstance (http://127.0.0.1:8100/build/main.js:10954:37)
at createViewNodes (http://127.0.0.1:8100/build/main.js:12303:49)
at createRootView (http://127.0.0.1:8100/build/main.js:12208:5)
at callWithDebugContext (http://127.0.0.1:8100/build/main.js:13339:42)
at Object.debugCreateRootView [as createRootView] (http://127.0.0.1:8100/build/main.js:12800:12)
at g (http://127.0.0.1:8100/build/polyfills.js:3:7133)
at l (http://127.0.0.1:8100/build/polyfills.js:3:6251)
at http://127.0.0.1:8100/build/polyfills.js:3:6805
at t.invokeTask (http://127.0.0.1:8100/build/polyfills.js:3:15213)
at Object.onInvokeTask (http://127.0.0.1:8100/build/main.js:4415:37)
at t.invokeTask (http://127.0.0.1:8100/build/polyfills.js:3:15134)
at n.runTask (http://127.0.0.1:8100/build/polyfills.js:3:10390)
at a (http://127.0.0.1:8100/build/polyfills.js:3:5313)
Ionic Framework: 3.0.1
Ionic App Scripts: 1.3.0
Angular Core: 4.0.0
Angular Compiler CLI: 4.0.0
Node: 6.10.1
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) Ap
答案 0 :(得分:2)
最近,您需要提供更改服务。您在app.module应用程序中使用的所有离子原生插件。因此,您应该将MediaCapture添加到app.module.ts文件的providers数组中。然后,它将开始工作
答案 1 :(得分:1)
您需要在app文件夹中找到的app.module.ts文件的poviders中添加MediaCapture类。
{-# LANGUAGE GADTs #-}
data CYSet a where
CYSet :: (Ord a) => Set.Set a -> (a -> b) -> CYSet b
liftCYSet :: (Ord a) => Set.Set a -> CYSet a
liftCYSet s = CYSet s id
lowerCYSet :: (Ord a) => CYSet a -> Set.Set a
lowerCYSet (CYSet s f) = Set.fromList $ map f $ Set.elems s
instance Functor CYSet where
fmap f (CYSet s g) = CYSet s (f . g)
main = putStrLn . show
$ lowerCYSet
$ fmap (\x -> x `mod` 3)
$ fmap abs
$ fmap (\x -> x - 5)
$ liftCYSet $ Set.fromList [1..10]
-- prints "fromList [0,1,2]"