1

I'm new in angular js. I am trying to include simple html file in my page.

This is my code:

<!DOCTYPE html>
<html ng-app="">
<head>
</head>

<body ng-controller="userController">

<div class="container">
  <div ng-include src="'about.html'"></div>
</div>

<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>

</body>
</html>

and about.html

<table class="table table-striped">
  <thead><tr>
    <th>Edit</th>
    <th>First Name</th>
    <th>Last Name</th>
  </tr></thead>
  <tbody><tr>
    <td>
      Edit
    </td>
    <td>ss</td>
    <td>dd</td>
  </tr></tbody>
</table> 

But it doesn't include 'about.html' page.

What's wrong with this code?(Sorry for bad english)

Thanks in advance.

1
  • Did you able to solve this problem? I am having the same issue. Please post the solution if you had solved this. Below answer does not work for me. Commented Oct 12, 2014 at 15:14

2 Answers 2

1

Try

<div ng-include="'about.html'"></div>

or

<ng-include src="'about.html'"></ng-include>
Sign up to request clarification or add additional context in comments.

3 Comments

I tried the same example with your answer but still I am not able to include the new HTML file. I got Page not found error.
I just copied the sample above and put the index.html and about.html files in the same folder, and removed the ng-controller from body since I do not have a js file with a controller in it and it worked fine for me.
Thanks. Can you please look at this question which I have posted.
0

The included file url should be relative to the client url of the including page. You are probably using some sort of web framework that abstracts your URL format.

You should put the included files together with other static files.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.