Search code examples
javascriptangularjsangularjs-ng-include

Angularjs data-ng-include not working


I am using angular js to create single page application. where i am calling a function which return url for data-ng-include.

Example:

<script>
  function theURL(){
  return 'demo.html';
  }
</script>


 <div ng-app="">
  <div data-ng-include="'theURL()'">
  </div>
 </div>

but the above code is not taking the url returned from the function hence the partial page is not load. can you please help?


Solution

  • Try:

    <div ng-include="theURL()"></div>
    

    But if it does not work, where is your Controller? Where is your $scope?

    $scope.theUrl = function(){
      return 'demo.html';
    }
    

    This inside your controller will work 100%.