在 Ionic 2 中使用翻译管道?
Using Translate pipe in Ionic 2?
有人有 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
像这样在您的@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/
有人有 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
像这样在您的@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/