This repository was archived by the owner on Apr 30, 2018. It is now read-only.
asynchronous angular-translate is not working with angular-formly #760
Open
Description
I load all my state level translation text via REST API asynchronously, Which is working totally fine when I use translation filter in HTML file but same is not working with angular-formly (when my API takes little time to give response).
Resolution : Angular-formly can put watch on label the way angular does and update translation text.
Here I am giving my code snippet to get clear idea
class LoginController {
constructor($translate){
this.$translate = $translate;
this.fields = this.getFields();
}
// Return Login form fields
getFields(){
return [
{
key: 'email',
type: 'input',
templateOptions: {
label: this.$translate.instant('REGISTER_LABEL_EMAIL') **// This not getting translated once API response comes**
},
expressionProperties: {
'templateOptions.label': '"REGISTER_LABEL_EMAIL" | translate' **// This not getting translated once API response comes**
}
}
}
}
<formly-form model="login.model" fields="login.fields" options="login.options" form="login.form">
<div class="form-group fpswd-wrapper text-right">
<a data-ui-sref="forgot-password" class="fpswd">{{'FORGOT_YOUR_PASSWORD_?' | translate}}</a> **// This gets translates once API response comes**
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6">
<md-switch class="md-primary" aria-label="Switch 1" ng-model="login.model.remember_me">
{{'REMEMBER_ME' | translate}} **// This gets translates once API response comes**
</md-switch>
</div>
<div class="col-sm-6 text-right">
<md-button type="submit" class="md-raised md-primary">{{'SIGN_IN' | translate}} **// This gets translates once API response comes**
<md-icon><i class="sp-right-arrow"></i></md-icon>
</md-button>
</div>
</div>
</div>
</formly-form>
</form>
Metadata
Metadata
Assignees
Labels
No labels