我正在使用 Ionic 3 和 Angular 5。我正在将 Youtube 视频嵌入到我的应用程序中,为此,我正在使用ngx-youtube-player. 但它给了我错误:
模板解析错误:无法绑定到“videoId”,因为它不是“youtube-player”的已知属性。1. 如果“youtube-player”是 Angular 组件并且具有“videoId”输入,则验证它是否是该模块的一部分。2. 如果“youtube-player”是 Web 组件,则将“CUSTOM_ELEMENTS_SCHEMA”添加到该组件的“@NgModule.schemas”以抑制此消息。3. 要允许任何属性,请将“NO_ERRORS_SCHEMA”添加到该组件的“@NgModule.schemas”。(" ][videoId]="fetch.video_id_" (ready)="savePlayer($event)" (change)="onStateChange($event)"> [错误 ->]) 在 JitCompiler._compileComponents (vendor.js: 114542)在vendor.js:114412在Object.then(vendor.js:81363)在JitCompiler._compileModuleAndComponents(vendor.js:114411)
我的 app.module.ts 是:
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { SuperTabsModule } from 'ionic2-super-tabs';
import { YoutubePlayerModule } from 'ngx-youtube-player';
import { MyApp } …Run Code Online (Sandbox Code Playgroud) 我在我的 Web 应用程序中使用 Angular 5。每当用户关闭浏览器窗口时,我想清除 localStorage 对象。
@HostListener("window:beforeunload", ["$event"])
clearLocalStorage(event) {
localStorage.clear();
console.log('####Destroy local storage####');
}
Run Code Online (Sandbox Code Playgroud)
由于应用程序中的其他逻辑(例如 SSO),我无法将上述代码粘贴到主app.component.ts中。
有没有办法,我可以使用不同的方法在角度应用程序中全局执行此操作。
请建议。
我是 Angular 6 的新手,正在为教师开发管理面板。我开发了整个管理面板,没有任何问题。开发管理客户端后给了我一个单独的 html 文件用于登录目的。这就是整个问题的开始。所以我决定通过路由来完成。我创建了管理面板和登录页面的布局。但现在我收到 **“app-root”选择器不匹配** 错误。
下面是我的 appComponent 打字稿
import { Component, OnInit, Inject } from '@angular/core';
import {ToastrService} from './services/toastr.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: [],
providers:[ToastrService]
})
export class AppComponent {
}
Run Code Online (Sandbox Code Playgroud)
这是我的index.html
<app-root>loading....</app-root>
Run Code Online (Sandbox Code Playgroud)
以下是我收到的错误
the selector "app-root" did not match any elements
at DefaultDomRenderer2.push../node_modules/@angular/platform-browser/fesm5/platform-browser.js.DefaultDomRenderer2.selectRootElement (platform-browser.js:1073)
at BaseAnimationRenderer.push../node_modules/@angular/platform-browser/fesm5/animations.js.BaseAnimationRenderer.selectRootElement (animations.js:229)
at DebugRenderer2.push../node_modules/@angular/core/fesm5/core.js.DebugRenderer2.selectRootElement (core.js:20837)
at createElement (core.js:17499)
at createViewNodes (core.js:19737)
at createRootView (core.js:19690)
at callWithDebugContext (core.js:20722)
at Object.debugCreateRootView [as createRootView] (core.js:20208)
at ComponentFactory_.push../node_modules/@angular/core/fesm5/core.js.ComponentFactory_.create (core.js:18029)
at ComponentFactoryBoundToModule.push../node_modules/@angular/core/fesm5/core.js.ComponentFactoryBoundToModule.create (core.js:7812) …Run Code Online (Sandbox Code Playgroud) 嗯,我正在处理一个项目并使用 Angular 5.2.0,我在其中使用他们的服务和一些模块完成了一个组件。想要此组件的公司更喜欢在其页面中包含像 Widget 这样的 Angular 应用程序。
我正在尝试一些像stackoverflow和 this选项这样的代码,但我不明白他们是如何做到这一点的。我想知道另一种方式或更好地解释这个问题。
我可以将所有应用程序打包在一个 JavaScript 中以包含在 HTML 页面中吗?
我有路径让路径="/";
当它调用这个路径时,Angular 会生成这样的路径:
http://localhost:4200/backend/api
Run Code Online (Sandbox Code Playgroud)
但是我需要
http://localhost/backend/api
Run Code Online (Sandbox Code Playgroud)
没有端口,如何在 Angular 中设置此选项?
我有下面的简化工作代码:
它尝试使用标签模拟并生成 3 行数据到 HTML。我使用#myTable“参考”它。正在传递数据并生成 Excel 文件(幸运的是)。
然而,数据是由excel格式化的(我认为在写入过程中它自己)。
谁能指导我如何不让 XLSX 不格式化并将数据导出到 Excel 中,如标签中所示?
超文本标记语言
<table #myTable class="table table-striped table-condensed text-nowrap">
<thead>
<tr>
<th></th>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let number of ['31.03.2020','10.10.2019','0013268']" class="form-group">
<td></td>
<td name="col1">{{ number }}</td>
<td name="col2">{{ number }}</td>
<td name="col3">{{ number }}</td>
</tr>
</tbody>
</table>
<button id="table-export-message" [tableElement]="myTable"
class="btn btn-default btn-primary float-right tableexport-string target" style="margin-right:10px">
<span class="fa fa-file-excel-o"></span>
Export Excel
</button>
Run Code Online (Sandbox Code Playgroud)
成分
private exportToTable() {
const ws: XLSX.WorkSheet = XLSX.utils.table_to_sheet(this.tableElement);
const wb: XLSX.WorkBook = …Run Code Online (Sandbox Code Playgroud) 所以我有以下组件:
export class ModuleComponentComponent implements OnInit {
dropzoneConf;
fileService = environment.getFileUrl;
constructor(
private moduleComponentService: ModuleComponentService) {
}
@Input()
selectedComponent: ModuleComponent;
ngOnInit() {
this.setDropZoneConfig();
}
}
Run Code Online (Sandbox Code Playgroud)
在那我有以下的HTML:
<h3 class="m-portlet__head-text m--font-success">
<input class="form-control" type="text" [ngModel]="selectedComponent.title" />
</h3>
Run Code Online (Sandbox Code Playgroud)
以及我在html中添加组件的方式:
<div class="col-lg-8 col-x1-12" *ngIf="selectedComponent != null">
<app-module-component [selectedComponent]="selectedComponent"></app-module-component>
</div>
Run Code Online (Sandbox Code Playgroud)
当我在输入字段中输入内容时,它不会更新selectedComponent.title变量
谁能告诉我发生了什么事?
我有一个使用android.support.v7.graphics.Palette的android应用程序,可从动态图像获取颜色信息,然后自定义活动的布局,以使用图像中的突变颜色。我的问题是,Angular 5有什么相似之处吗?我想将此项目的Web版本建模为尽可能接近android版本。这将意味着在选择图像后动态设置一些样式颜色。
更新:我一直在寻找JavaScript的ColorThief()。但是我不确定如何从Angular 5组件中访问它。
谢谢PK