小编Myo*_*ara的帖子

界面无法在角度2模块中导出?

我试图在NgModule声明中导出一个接口并导出并在编辑器中获取此错误(Visual Studio代码): [ts] 'MyInterface' only refers to a type, but is being used as a value here.

这是示例代码Edit-1:

import { NgModule }           from '@angular/core';
import { CommonModule }       from '@angular/common';
import { FormsModule }        from '@angular/forms';
import { MaterialModule }     from '@angular/material';
import { MyInterface }        from './my.interface';
import { MyService }          from './my.service';

@NgModule({
  imports:      [ CommonModule, FormsModule,  MaterialModule.forRoot()  ],
  declarations: [ MyInterface],//<- this is causing the message
  exports:      [ MyInterface],
  providers:    [ MyService ]
})
export …
Run Code Online (Sandbox Code Playgroud)

typescript angular

22
推荐指数
2
解决办法
2万
查看次数

你能在 ejs 文件中使用 vue.js 吗?

抱歉,我是 node.js 的新手,想知道是否允许我们在 ejs 文件中使用 vue.js。

ejs node.js vue.js

5
推荐指数
2
解决办法
6481
查看次数

youtube.d.ts需要在Angular 2中使用的youtube-iframe-api文件

我尝试使用youtube iframe api来显示和控制具有平滑angular2集成的视频片段.并且尊重typescript的类型概念对于webpack编译器和我来说很重要:).

快速设置我的测试:

使用@ angular/cli(版本1.0.0-beta.32.3)来设置和安装ng2-youtube-player,然后进行两项小调整:

ng new test002
cd test002
npm install ng2-youtube-player --save-dev
Run Code Online (Sandbox Code Playgroud)

app.module根据ng2-youtube-player进行了扩展,但是在app.component中我有一个小的修正和一个错误:

import { Component } from '@angular/core';

@Component({
    selector: 'app-root',// app renamed to app-root
    template: `
        <youtube-player
      [videoId]="id"
      (ready)="savePlayer($event)"
      (change)="onStateChange($event)"
    ></youtube-player>
    `
})
export class AppComponent {
  player: YT.Player;// Error: Cannot find namespace 'YT'
  private id: string = 'qDuKsiwS5xw';

    savePlayer (player) {
    this.player = player;
    console.log('player instance', player)
    }
  onStateChange(event){
    console.log('player state', event.data);
  }
}
Run Code Online (Sandbox Code Playgroud)

对于错误,我使用youtube.d.ts文件伪造了命名空间:

// …
Run Code Online (Sandbox Code Playgroud)

youtube-api typescript youtube-iframe-api angular

1
推荐指数
1
解决办法
3980
查看次数