i18next / ng-i18next

translation for AngularJS using i18next
https://github.com/i18next/ng-i18next
MIT License
161 stars 54 forks source link

ng-model not working when using ng-i18next #21

Closed DickLemm closed 11 years ago

DickLemm commented 11 years ago

In an app I have a textarea in which I paste or type some content. This content is bound to the model. To make this visible I have a second textarea which shows this content. As soon as I use directive ng-i18next on the first textarea, the content I type in the first textarea is not bound to the model and is not showing up in second textarea!

<textarea id="pasteArea" ng-i18next="[title]Paste-your-excel-here" ng-model="pastedRawExcel" />

bugwelle commented 11 years ago

Ok, I hope I understood it correctly. You have some code like this, right?:

<textarea ng-model="myModel" ng-i18next="[title]yourTitle"></textarea>
<textarea>{{myModel}}</textarea>

I created a JSBin example (modified; I use placeholder and other stuff): http://jsbin.com/aNEXOqa/1

Because I had the same problem, I had to search for the soution, which is that you have to change scope: true to scope:false in https://github.com/archer96/ng-i18next/blob/master/dist/ng-i18next.js#L191 on line 191. I put this change also in the example. Now it works fine ;)

http://docs.angularjs.org/guide/directive scope - If set to: true - a new scope will be created for this directive. If multiple directives on the same element request a new scope, only one new scope is created. The new scope rule does not apply for the root of the template since the root of the template always gets a new scope.

I will push this change to GitHub later. I have to check if everything still works fine :)

Thanks for reporting this issue :+1:

~Andre

Edit://There was something more to be changed. Please use the latest version 0.2.7 ;)