これは素晴らしいフォントプラグインではありません。これは私が書いたものです。 AppModuleに追加すると、動作しません。'fa'にはバインドできません。 'i'のプロパティが既知ではありません。
AppModule
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from "@angular/http";
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app.routing.module';
import { HomeComponent } from './home/home.component';
import { DataModule } from './data/data.module';
import { NavtreeComponent } from './sidebar/navtree.component';
import { JsonifyPipe } from './jsonify.pipe';
import { DebugPipe } from './debug.pipe';
import { PagesModule } from './pages/pages.module';
import { PanelsComponent } from './panels/panels.component';
import { IsolateScrollDirective } from './controls/isolate-scroll.directive';
import { FontAwesomeDirective, FontAwesomeLinkComponent } from './controls/font-awesome.component';
@NgModule({
declarations: [
AppComponent,
HomeComponent,
NavtreeComponent,
JsonifyPipe,
DebugPipe,
PanelsComponent,
IsolateScrollDirective,
FontAwesomeDirective,
FontAwesomeLinkComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpModule,
DataModule.forRoot(),
PagesModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
フォントawesome.component.tsそれが使用さ
import { Component, Directive, ElementRef, Input, HostListener, OnInit, HostBinding } from '@angular/core';
import { trigger, state, style, transition, animate } from '@angular/core';
@Component({
selector: 'a[fa]',
template:
`<i [fa]="fa"
[@spinonce]="fa === 'refresh' ? clicked : 0"
(@spinonce.done)="clicked=0"></i>
`,
animations: [
trigger('spinonce', [
//state("void", style({
// transform: 'rotate(0deg)'
//})),
transition('0 => 1', [
animate('1000ms ease-in-out', style({
transform: 'rotate(360deg)'
}))
]),
])
]
})
export class FontAwesomeLinkComponent {
@Input() fa: string;
@Input() class: string;
@HostBinding('class')
get getClass(){
return (this.class || '') + ' fa';
}
@HostBinding('attr.aria-hidden')
get ariaHidden() {
return true
}
@HostListener('click')
onLinkClicked() {
this.clicked++;
}
clicked = 0;
}
@Directive({
selector: 'i[fa]'
})
export class FontAwesomeDirective {
@Input() public fa: string;
@Input() public class: string;
@HostBinding('class')
public get classStr() {
return 'fa fa-' + this.fa + ' ' + (this.class || '');
}
@HostBinding('attr.aria-hidden')
public get ariaHidden() { return true }
constructor() {
}
}
<button class="ui-button" (click)="importOrders()">Import Orders</button>
<div class="status-bar"></div>
<div class="order-list">
<div *ngFor="let item of orders" class="success-{{item.success}}">
<div class="icon-block"><i [fa]="item.icon"></i></div>
<span>{{item.order.email}}</span>
</div>
</div>
エラー
Can't bind to 'fa' since it isn't a known property of 'i'. ("">
<div *ngFor="let item of orders" class="success-{{item.success}}">
<div class="icon-block"><i [ERROR ->][fa]="item.icon"></i></div>
<span>{{item.order.email}}</span>
</div>
"): ng:///PagesModule/[email protected]:29 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:
Can't bind to 'fa' since it isn't a known property of 'i'. ("">
<div *ngFor="let item of orders" class="success-{{item.success}}">
<div class="icon-block"><i [ERROR ->][fa]="item.icon"></i></div>
<span>{{item.order.email}}</span>
</div>
"): ng:///PagesModule/[email protected]:29
odd。私は問題を再現できませんでした。 https://plnkr.co/edit/jYhtkDr62cc6P46AGuoT?p=preview – LLai