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));
Share:
14,336
nitansh bareja
Author by

nitansh bareja

Hi am Nitansh Software engineer at Aricent Group.

Updated on July 29, 2022

Comments

  • nitansh bareja
    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
    nitansh bareja about 10 years
    ok that is for internationalization, But I am using PolyGlotJs for this. Any Idea how to render-views in Angular?
  • Jayantha Lal Sirisena
    Jayantha Lal Sirisena about 10 years
    How do you translate the content , is it from the server side ?
  • nitansh bareja
    nitansh bareja about 10 years
    No 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
    Jayantha Lal Sirisena about 10 years
    I think you can $compile the HTML again. See my edit
  • nitansh bareja
    nitansh bareja about 10 years
    this 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
    Jayantha Lal Sirisena about 10 years
    Ah ok. Then keep the content as a template. keep the html somewhere hidden and compile that and insert it in to the #content div.