1

Although it discussed here: AngularJS with Sharepoint 2010 not working And uses of timeout in order to make the page being loaded synchronous (I don't like this solution) - it's not work.

I have loaded the html of the webpart page after the angular is loaded:

window.onload = function(){
    setTimeout(function(){       
        str+='<p>Name : <input type="text" ng-model="name" placeholder="Enter 
        name here"></p>'        
        str+='<h1>Hello {{name}}</h1>'                
        str+='<button id="submit"></button>'

        document.getElementById("ngApp").innerHTML=str;    
    }, 2500);
}

The output is: "Hello {{name}}"

    <script src=".../angularjs.js"></script>
<script src=".../code.js"></script>
  • Hi Eyal, are you using a server-side webpart to add HTML to the page? – Denis Molodtsov Mar 6 '18 at 15:44
  • Hi Denis - not, everything in the Front – Eyal Segal Mar 7 '18 at 6:01
2

When Loading Content or Libraries Async, you have to initialize AngularJS manually, after all your content and libraries are loaded. This is called manual initialization (or sometimes manual bootstrapping):

angular.bootstrap(document, ['myApp']);

Refer to the Angular Documentation for a detailed description.

  • Thank you! whre shoul I put the bootstrapping? – Eyal Segal Mar 7 '18 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.