How can I save a page in AngularJS - javascript

Im playing with Angular Tabs.
I Include one url property in my model so I can work with ng-include="tab.url" and display a diferent page for each tab. (is same page just different parameter for tab)
But doesnt make sense download the content every time the user click on the tab.
Is there a way I can save the page to save the content locally so only get the page from the server once?

You could load the templates directly into $templateCache. Angular will automatically check this whenever you specify a template src with ng-include before attempting to retrieve your template from a remote location.

Related

The script is working just after one refresh on angular

I tried to implement a tree view similar with this( https://iamrohit.in/javascript-css-horizontal-employee-treeview/ ) but the script only work just after first refresh of the page, I'm using angular, is there an option to load the page before so the user doesn't need to refresh the page every time because that's not my intention on this project.

Force Reload a page before loading when clicked on the link attribute

I have a link on my page which opens up a text file located on the file server. when user clicks on the link it opens up the text file as fetched from the file server but this file gets updated when user refreshes the page. subsequently when user clicks on the same link after refresh to open the file it displays the old file. but when did a ctrl+f5(server cache refresh) on the text file tab it then refreshes and displays the updated file. but end user doesn't do a force refresh. looking to see if there is any work around in JavaScript to do a force refresh of the text file page before loading.
I would suggest monitoring the anchor in the URL to avoid a reload,
that's pretty much the point of using anchors for control-flow. But
still here goes. I'd say the easiest way to force a reload using a
simple anchor-link would be to use
where in place of $random insert a random number (assuming "dummy" is
not interpreted server side). I'm sure there's a way to reload the
page after setting the anchor, but it's probably more difficult then
simply reacting to the anchor being set and do the stuff you need at
that point.
Then again, if you reload the page this way, you can just put
myanchor2 as a query parameter instead, and render your stuff server
side.
Edit
Note that the link above will reload in all circumstances, if you
only need to reload if you're not already on the page, you need to
have the dummy variable be more predictable, like so
I would still recommend just monitoring the hash though.

How to get full html sourcecode after page dynamically loaded

I need to save my .php file as an .html for backup with using PHP whenever page called (I am going to use ob_start() for it). But the page content is not static. I am using AJAX to load the content.
That's why view-source: does not show the dynamic data, only chrome inspector show them. But I need to save the page with all elements after page loads. Is it possible or not?
BTW after page loads, there is no any other ajax call (on click or something). Page loads all content on init.
Thanks in advance.

How to tell if an Angularjs page is loaded from a refresh or navigated to by link?

In Angularjs pages are loaded via ajax calls to templates, and the browser never reloads it's full content (a single app). However you can directly link to a page itself and Angularjs figures out which contents it needs to load.
How can I tell if a page has been directly linked to (maybe from a refresh) or if it was dynamically loaded (for example, when using location.path('/somepath');)?
I've tried looking in the docs and I haven't found anything. I can set a local storage variable, but that seems overkill.
You can know it before any Angular code. You can look to the window.location object and check the URL. For example, just do it before the angular.module('myModule', [...]) line.
var url = window.location.href;
if (url.contains('/somepath')) {
console.log('do something !');
}
angular.module('myModule', [...])
// Angular code goes on ...
Page is never actually refreshing itself. All files are preloaded into browser and then only thing refreshing is content.
When you manually refresh the page angular loads again as it is the first time you open the page.

How to use angular routing for directly access to content

how can i use Angular routing to access clickable content ( appears when click on a specific tab) when insert URL directly in browser?
for example I have a menu when i click on first tab some content apear and when click on another tab show something else and url was change but when I insert that url directly in the address bar, the content does not show. how can i solve this problem ?
Are you getting a 404 when putting the url directly in the browser address bar?
If so, it sounds like you need to configure your web server to route all requests to the page AngularJS loads from. AngularJS routing will then take over and load the content as expected.

Categories

Resources