0
我試着去創造angular2和IM運行到問題小寫管那裏即時得到Angular2 - 管道和語法
syntax errors got ';'
應用程序/ lowercase.ts
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({ name: 'lowercase1'})
export class LowerCasePipe1 implements PipeTransform {
transform (value: string): string {
if (!value) return value;
if (typeof value !== 'string'){
throw new Error('Invalid pipe value: ', value);
}
return value.toLowerCase();
}
}
應用程序/應用程序.component.ts
import {Component} from '@angular/core';
import {LowerCasePipe1} from './lowercase';
@Component({
selector: 'app',
pipes: [LowerCasePipe1],
template: '<h1>{{"SAMPLE" | lowercase1 }} </h1>'
})
export class App {
console.info('lower case app')
}
應用程序/ index.ts
import {bootstrap} from '@angular/platform-browser-dynamic';
import {App} from './app.component';
//
bootstrap(App)
這裏是plunkr:http://plnkr.co/edit/coB5AGWvpihUvCnBtX9D?p=preview