0

I have a HTML file where on click of a hyperlink i need to load another HTML file in a DIV inside the first HTML file. Can i achieve this in AngularJS? If so how? Also there is ng-Grid in the HTML. here is the code am trying:

1

3 Answers 3

0

The nice thing about hyperlinks is that they generally map a HTTP GET request to a reusable url.

If you use $routeProvider and

<a href="#/table">table</table>
<div ng-view="table"></div>

like this: http://plnkr.co/edit/ZlVZZYw9wQIDza7NeVtu?p=preview

You can ctrl-click the the link, open the link in new tabs/windows or share the link.

Sign up to request clarification or add additional context in comments.

5 Comments

But there is ng-grid in the HTML am trying to load. HTML is getting loaded. But data in the Grid is not loading... Here is the plunk: plnkr.co/edit/5ghLaC7hWnUS2oqCKaiU?p=preview
The template you include in the #about route, should only be a html fragment and you should probably load your table controller logic in aboutController, like so: plnkr.co/edit/1pqGmPh4pbWJTCrOJqIQ?p=preview
what ever is there is the plunker is what i need. But if i use that am getting an error. Error: Unknown provider: $sceProvider <- $sce <- $route <- ngViewDirective
Do you get $sceProvider error on this page: plnkr.co/edit/1pqGmPh4pbWJTCrOJqIQ?p=preview ? I can't see the $sce service referenced anywhere in the code.
Its working now. But why is the CSS not applying for the Grid?
0

Here is the code:

<a ng-click="showAdditionalContent = true">Show</a>
<div ng-if="showAdditionalContent" ng-include="html/file.html">

</div>

3 Comments

But there is ng-grid in the HTML am trying to load. HTML is getting loaded. But data in the Grid is not loading... Here is the plunk: plnkr.co/edit/5ghLaC7hWnUS2oqCKaiU?p=preview
You have problems in your code. For example you bootstrap your app for second time app = angular.module('myApp', ['ngGrid']);. Just don't mess your js, place it in separate file
even if i remove that piece of code its not working.
0

You can also use the ngBindHtml directive too.

https://docs.angularjs.org/api/ng/directive/ngBindHtml

1 Comment

But there is ng-grid in the HTML am trying to load. HTML is getting loaded. But data in the Grid is not loading... Here is the plunk: plnkr.co/edit/5ghLaC7hWnUS2oqCKaiU?p=preview

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.