how to remove caching from files that are used as templates in
ng-include="path/to/file.html"
I tried to using $templateCache.removeAll();
but its not working
Is there any way we can clear cache in angular when the application loads?
$templateCache.removeAll() should really work.
You could try running $cacheFactory('templates').removeAll(); - but that is really what $templateCache.removeAll() is doing behind the scenes.
What does the surrounding implementation look like / in what context are you calling this method? Would it be possible for you to setup a plunker/fiddle for the case?
I had this trouble and I solved by adding a time parameter to a all URLs on my project, like path/to/file.html?t=4487664434
You can get the date ticks with the javascript funcion getTime(), from Date class.
Related
I am working on a project that uses Angular1, we hit the problem where when we change an html template the users will not see the change until a hard refresh is performed. Ideal would be to have the cache service to check a timestamp and invalidate the cached file. As an example now I edited a template used by the $stateProvider.
My questions is what solutions or best practices are used to solve the problem?
P.S since our JS files are combined in 1 file we fixed the problem there by appending a timestamp in the script tag from our PHP backend
Interesting question! We've had the same issue in a project that uses Angular1.x. We solved it using angular-cache-buster.
It basically helps you put a httpInterceptor. All you need is have ngCacheBuster in module dependency injection, and inject httpRequestInterceptorCacheBusterProvider in the .config of your app to set the match list.
For example,
httpRequestInterceptorCacheBusterProvider.setMatchlist([/.*api.*/], true);
this tells it to cache everything except REST api requests. You can learn more about the configuration here.
Can anyone suggests me angularjs framework with fabricjs.
I'm going to build angularjs application , having canvas (FabricJS).
Thanks in advance .
I would not recommend you to use angularjs with fabricjs.
The project I'm currently working on uses this combination.
We get a lot of troubles related to scope. E.g. if you need to update something in angular from fabricjs, you need to determine if angular digest loop is currently running and if not, run it.
You could try React + fabricjs instead. React looks more flexible and much faster works with DOM.
In my Angular project (seat reservation system) I use Fabric.js (for seat plan editor) without any complications. I have no problem with displaying more than 1000 objects.
Here you can find my "Hello World" Angular + Fabric.js project.
Here you can find my answer on question "How to use / include fabricjs in Angular2".
You should not worried about how bind them togheter. Keep it simpe.
Fabric will trigger a series of event from user actions, a bunch of event similar firing function that you can find in your doc. Use those to update your app state.
For all the rest keep a reference of the canvas in you scope and use it normally.
I am new to angular and it seems very interesting
I am creating a template for a promotional page and struggling to understand what is causing an issue on it - half of the script stopped working...
My fiddle is in here see >
fiddle example
or Plunker
I have working example without route...
Can you advice me how to fix this issue please
First of all, i'd suggest you to separate your project to different files based on best practises
Secondly, 'config, controller, factory' etc are methods of angular.module object. So you need to retrieve it first like
angular.module('<moduleName>').config(...)
or use some variable.
http://plnkr.co/edit/CK5R2cS7Zd9T9Kun9Epc?p=preview
Currently I'm looking for a plugin/js that I can use to show my users a small walkthrough of my site. I have jquery and angular both running on my page.
I have been using Chardin.js (https://github.com/heelhook/chardin.js). This plugin works and is simple, however when i try to include angular elements chardin.js will not be able to find the elements to display.
SO I'm trying to find a way to integrate this plugin with angular. Unless there are some better plugins that work better for this in angular. Thanks!
I agree with #Ben_Coding,
Angular-Intro is pretty good, light-weight, and no dependency on jQuery.
I'm working on a big project. This project already has complicated structure. Most pages are generated on server-side with Twig.
Now we move the project to AngularJS.
It is not possible to use angular-way routing on whole project just now. But somewhere, it is necessary.
And here comes our trouble.
If I add 'ng-app' in html tag, for example, on some pages angular add hash in url.
And what is strange for me, that it's not everywhere.
On start page (project/profile9868766), url is clear as it is. But on some other (project/community/list), angular does something like that: project/community/list/#list .
And it is extremely undesirable.
There are no any angular routes, configured in $route service yet.
Please, help me to find out what causes that behavior, and what should i do to make all the things to go right way.
I want to add ng-app in html tag and not get any troubles with existing code, that may use hashes. And I want to use angular directives, controllers and other stuff, including $location service to set and track hashes on some pages. And later move everything to Angular and only after that start using Angular routes.
Thanks!
PS: English is not my native language, sorry about some weird constructions and mistakes. ))
Make sure to turn on html5mode
http://docs.angularjs.org/guide/dev_guide.services.$location
But the hash is inevitable on non-html5 browser.
The latest version of angular (v1.0.7) seems to have fixed this issue.