How to re-render views using Angular JS
14,336
Have you looked at the angular-getText libary ,
Or you can $compile the HTML using angular again. You can simply do like this,
var content=angular.element('#translatedContent');
var scope=content.scope();
$compile(content.contents())(scope));
Comments
-
nitansh bareja almost 2 years
I want to re-render all the views present on my page.I have Header, Footer and Body view. In Header view i have a dropDown in which user can select the Language Preference. On clicking on language prefrence all the view should be re-render. Is it Possible in Angular?
In BackboneJs i simply call the render function again on that particular event. Is there some same kind of functionality provided by AngularJs?
Thanks in Advance
Header Template (language Prefrence Dropdown Code)
<li class="dropdown"> <a id="dLabel" role="button" data-toggle="dropdown" data-target="#"> Language Preferences<b class="caret"></b> </a> <ul class="dropdown-menu dropdown-manual"> <li id="English" ng-click="englishConversion()">English</li> <li id="French" ng-click="frenchConversion()" >French</li> </ul> </li>
is there any inbuilt function which i can call in englishConversion and frenchConversion to re-render the view/views?
-
nitansh bareja about 10 yearsok that is for internationalization, But I am using PolyGlotJs for this. Any Idea how to render-views in Angular?
-
Jayantha Lal Sirisena about 10 yearsHow do you translate the content , is it from the server side ?
-
nitansh bareja about 10 yearsNo it is on client side.we just wrap the string values in templates inside polyglot.t('String').And we first have to initialize the Polyglot. For more check this link puigcerber.wordpress.com/2013/03/21/…
-
Jayantha Lal Sirisena about 10 yearsI think you can
$compile
the HTML again. See my edit -
nitansh bareja about 10 yearsthis worked but i got an issue the data which is in ng-repeat just is now doubling of it's initially value. like on the first time i have 2 tabs after exectuing this function my tab count increase to four.
-
Jayantha Lal Sirisena about 10 yearsAh ok. Then keep the content as a template. keep the html somewhere hidden and compile that and insert it in to the #content div.