我正在使用Angular2 Final版本(2.1.0).当我想显示公司列表时,我收到了这个错误.
在file.component.ts:
public companies: any[] = [
{ "id": 0, "name": "Available" },
{ "id": 1, "name": "Ready" },
{ "id": 2, "name": "Started" }
];
Run Code Online (Sandbox Code Playgroud)
在file.component.html:
<tbody>
<tr *ngFor="let item of companies; let i =index">
<td>{{i}}</td>
<td>{{item.name}}</td>
</tr>
</tbody>
Run Code Online (Sandbox Code Playgroud) 我刚从github克隆angular2-seed项目并按照步骤进行操作,但是我在VS代码中得到了这个警告[ts]对装饰器的实验支持是一个在将来的版本中可能会发生变化的功能.设置'Exxperimentaldecorators'选项以删除此警告.
我找不到能帮助我在Angular2中解决这个问题的东西.当我选择一行时,我想设置一个css类.(不使用jQuery)
<table class="table table-bordered table-condensed table-hover">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Website</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of companies" (click)="selectedCompany(item, $event)">
<td>{{item.name}}</td>
<td>{{item.email}}</td>
<td>{{item.website}}</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我正在使用Angular2最终版本
我正在尝试在Ionic 2应用程序中使用TouchID。我有iphone 5c,所以无法在真实设备上测试。
我导入了包裹:
import { TouchID } from 'ionic-native';
Run Code Online (Sandbox Code Playgroud)
然后,我测试了第一个功能(我已经在模拟器的硬件部分中激活了touchID):
TouchID.isAvailable()
.then(
res => console.log('TouchID is available!'),
err => console.error('TouchID is not available', err)
);
Run Code Online (Sandbox Code Playgroud)
一切正常。现在我想做的就是测试这个功能:
TouchID.verifyFingerprint('Scan your fingerprint please')
.then(
res => console.log('Ok', res),
err => console.error('Error', err)
);
Run Code Online (Sandbox Code Playgroud)
可以在模拟器上进行测试吗?仿真器可以听指纹动作吗?
我正在尝试为我的项目添加一个模态,所以我找到了这个库:ng2-bootstrap
我首先使用命令安装它: npm install ng2-bootstrap --save
我的班级看起来像:
import { Directive, ElementRef, Input, Renderer, AfterViewInit, OnDestroy } from
@angular/core';
import { ModalModule } from 'ng2-bootstrap/ng2-bootstrap';
@Directive({
selector: '[bsModal]',
exportAs: 'bs-modal'
})
export class ModalDirective implements AfterViewInit, OnDestroy {
@Input()
public set config(conf:ModalOptions) {
this._config = this.getConfig(conf);
};
@Output() public onShow:EventEmitter<ModalDirective> = new EventEmitter();
@Output() public onShown:EventEmitter<ModalDirective> = new EventEmitter();
@Output() public onHide:EventEmitter<ModalDirective> = new EventEmitter();
@Output() public onHidden:EventEmitter<ModalDirective> = new EventEmitter();
}
Run Code Online (Sandbox Code Playgroud)
但我得到了这个错误:
class 'ModalDirective' incorrectly implements interface 'AfterViewInit'