1

Ionic 2 の翻訳パイプの実例を持っている人はいますか?

console.log("trans: "+this.trans.translate('Location')); // works fine in code

http://ionicframework.com/docs/v2/utils/translation/によると、テンプレートの構文は次のようになります。

<h2>{{'My example key' | translate}}</h2>

私にとっては、これにより次のJSエラーが発生します。

EXCEPTION: Cannot find pipe 'translate'. in [null]BrowserDomAdapter.logError @ app.bundle.js:36432
4

1 に答える 1

3

次のように @Page に TranslatePipe をインポートして挿入します。

import {Page, TranslatePipe} from 'ionic/ionic';

@Page({
  templateUrl: 'build/pages/home/home.html',
  pipes: [TranslatePipe]
})

参照: http://www.joshmorony.com/how-to-use-pipes-to-manipulate-data-in-ionic-2/

于 2016-01-15T01:23:19.880 に答える