Angular(5)cli - Cloudinary - <cl-image>错误

时间:2017-10-30 08:37:58

标签: angular angular-cli cloudinary

所以,

我正在尝试在我们的网站上实施cloudinary 按照说明我有这个:

app.module

...
import { CloudinaryModule } from '@cloudinary/angular-4.x';
import { Cloudinary } from 'cloudinary-core/cloudinary-core-shrinkwrap';
...


const cloudinaryLib = {
  Cloudinary: Cloudinary
}
...
@NgModule({
  declarations: [AppComponent],
  imports: [
    CloudinaryModule.forRoot(cloudinaryLib, {cloud_name: 'mycloudname'})
    ...
  ]
  ...
});

然后在我看来我有

<cl-image public-id="id-to-the-asset"></cl-image>

在执行 ng serve 时出现错误

ERROR in Error at C:/DEVELOPMENT/app1/src/app/pages/a/a-page.component.html(10,3):  ("
  ></div>

  [ERROR ->]<cl-image public-id="site-assets/aaa"></cl-image>

  <div class="container">
")

任何想法为什么? 错误没有说明为什么

我正在使用

"@angular/core": "^5.0.0-rc.8",
...
"cloudinary-core": "^2.3.0",
"@cloudinary/angular-4.x": "^1.0.0",
...
"@angular/cli": "^1.5.0-rc.6",

另外,注意到如果我从视图中删除cl-image并让cli构建页面,我会收到以下警告:

  

警告   ./node_modules/@cloudinary/angular-4.x/node_modules/@angular/core/@angular/core.es5.js   5659:15-36严重依赖:依赖的请求是一个   表达       在ImportLazyContextDependency.getWarnings(C:/ DEVELOPMENT / app1 \ node_modules \ webpack \ lib \ dependencies \ ContextDependency.js:39:18)       在Compilation.reportDependencyErrorsAndWarnings(C:/ DEVELOPMENT / app1 \ node_modules \ webpack \ lib \ Compilation.js:703:24)       在Compilation.finish(C:/ DEVELOPMENT / app1 \ node_modules \ webpack \ lib \ Compilation.js:561:9)       at applyPluginsParallel.err(C:/ DEVELOPMENT / app1 \ node_modules \ webpack \ lib \ Compiler.js:506:17)       在C:/ DEVELOPMENT / app1 \ node_modules \ tapable \ lib \ Tapable.js:289:11       at _addModuleChain(C:/ DEVELOPMENT / app1 \ node_modules \ webpack \ lib \ Compilation.js:507:11)       at processModuleDependencies.err(C:/ DEVELOPMENT / app1 \ node_modules \ webpack \ lib \ Compilation.js:477:14)       at _combinedTickCallback(internal / process / next_tick.js:73:7)       at process._tickCallback(internal / process / next_tick.js:104:9)@ ./node_modules/@cloudinary/angular-4.x/node_modules/@angular/core/@angular/core.es5.js   @   ./node_modules/@cloudinary/angular-4.x/src/cloudinary-image-source.directive.js   @ ./node_modules/@cloudinary/angular-4.x/src/cloudinary.module.js @   ./src/app/app.module.ngfactory.js @ ./src/main.ts @ multi   webpack-dev-server / client?http://0.0.0.0:0 ./src/main.ts

     

警告   ./node_modules/@cloudinary/angular-4.x/node_modules/@angular/core/@angular/core.es5.js   5675:15-102严重依赖:依赖的请求是一个   表达       在ImportLazyContextDependency.getWarnings(C:/ DEVELOPMENT / app1 \ node_modules \ webpack \ lib \ dependencies \ ContextDependency.js:39:18)       在Compilation.reportDependencyErrorsAndWarnings(C:/ DEVELOPMENT / app1 \ node_modules \ webpack \ lib \ Compilation.js:703:24)       在Compilation.finish(C:/ DEVELOPMENT / app1 \ node_modules \ webpack \ lib \ Compilation.js:561:9)       at applyPluginsParallel.err(C:/ DEVELOPMENT / app1 \ node_modules \ webpack \ lib \ Compiler.js:506:17)       在C:/ DEVELOPMENT / app1 \ node_modules \ tapable \ lib \ Tapable.js:289:11       at _addModuleChain(C:/ DEVELOPMENT / app1 \ node_modules \ webpack \ lib \ Compilation.js:507:11)       at processModuleDependencies.err(C:/ DEVELOPMENT / app1 \ node_modules \ webpack \ lib \ Compilation.js:477:14)       at _combinedTickCallback(internal / process / next_tick.js:73:7)       at process._tickCallback(internal / process / next_tick.js:104:9)@ ./node_modules/@cloudinary/angular-4.x/node_modules/@angular/core/@angular/core.es5.js   @   ./node_modules/@cloudinary/angular-4.x/src/cloudinary-image-source.directive.js   @ ./node_modules/@cloudinary/angular-4.x/src/cloudinary.module.js @   ./src/app/app.module.ngfactory.js @ ./src/main.ts @ multi   webpack-dev-server / client?http://0.0.0.0:0 ./src/main.ts

EDITED

我降级到最新的4.x角度版本并且没有出现构建错误或警告......但我确实得到了

'cl-image' is not a known element:

所以,仍然无法正常工作

1 个答案:

答案 0 :(得分:1)

它对我有用。我建议你需要

import * as cloudinary from 'cloudinary-core/cloudinary-core-shrinkwrap';

CloudinaryModule.forRoot(cloudinary,
  {
    cloud_name: 'ccloudd'
  } as CloudinaryConfiguration),