I have a login system maded with AngularJS. Now I want that if somebody is not logged in the template is blank. If somebody logs in the template will continue. The problem is that when you load the page the templates loads also. So when you log in you get a blank page, you need the reload the page and then its working.
Is there a function that refresh the template? So that you don`t have to reload the page?
When you use Angular it's best to have the web server serve static content (images, css, js, and static html) and data (almost always JSON).
In your case I would always serve the template and use ng-show and/or ng-hide to toggle the template display. Here's a simple example:
Instead of
<?php
echo "Hello " + $name;
?>
Do this
greeting.html
<div ng-show="authenticated">{{name}}</div>
greeting.json web service (I'm not a php person, my php might not be entirely correct):
<?php
json_encode($name)
?>
Related
I've a website called VoteCircle (www.votecircle.com), but i noted that it doesn't display well for Google Bot/Optimizely (used for A/B tests). It shows only the content that AREN'T in ng-view. All content in ng-view isn't displayed.
it was made in AngularJS and the content in ng-view isn't displayed for those bots/previews that i mentioned.
What's the best way to fix that?
Please, see attached screenshot.
Thanks.
There is a pretty easy fix for this. In your URL bar, click on the small key and enable mixed content. The browser blocks loading mixed content in the editor by default (HTTPS and HTTP resources combined). By enabling it you can load the rest of the page in the editor.
I have a problem in hand in AngularJS and need some pointers.
I have a view where I want to embed an external url (e.g. http://www.w3schools.com). The embeded html page should respond to events like click and touch like a normal html page.
I have used ng-include directive to get that working.
Here is a code snippet:
<ion-content>
<div ng-include src="'http://www.w3schools.com'"</div>
</ion-content>
If I load the external html, I am getting the external webpage loaded, but all the links inside the page are broken. If I click on any link inside the loaded page, all links point to localhost now instead of the external url.
How can I fix this problem?
Thank in advance!
It sounds like you really just want to host the external site inside your view, and then you should just link it in an iframe.
<iframe src="http://www.w3schools.com"></iframe>
If you want something magic/dynamic stuff to happen, you will need to parse the content and rewrite the urls, attach handlers etc. The reason your ng-include does not work like expected is because it only reads the content of that url and embeds it into your view "as-if" it was just a template you made (including angular markup) and wanted to host externally for some reason.
I have an issue where my site doesn't load unless the user enters www. For example, if the user enters mysite.com (as opposed to www.mysite.com, or http://www.mysite.com), then my site only partially loads. I suspect this is either an issue with my use of angularjs or angular ui-router. My site has an html wrapper template that is used on every page. That is what is being loaded if the user doesn't enter www, but the template partial that should be inserted into that particular page isn't being loaded unless www is entered. For example, www.mysite.com/page would consist of my html wrapper template AND a page.html template partial that is supposed to be inserted into the html wrapper template, but page.html is only being loaded if the user enters www. Any ideas?
My single page angularjs application seems to work fine in IE9+ until you edit an object and reload the page. If you modify a field (change Name from "You" to "Me") then press save the server gets the update and updates the database. If you then refresh the page the field has its original value (Name is "You"). Refreshing the page does not call the $routeProvider and does not go to the server.
None of this happens on Chrome, Firefox, Safari, or their mobile counterparts.
One of the biggest issues with IE is that it doesn't handle console.log unless the console is open and will break just about everything. Not sure if this is your problem, but always good to check.
My server side is an ASP.Net MVC app so I disabled caching.
Set the OutputCache attribute on the whole controller or certain actions
[OutputCache(Location = OutputCacheLocation.None)]
public class HomeController : Controller
{
//All actions in here won't be cached.
}
Used #KCD's answer from this question:
How do I add site-wide no-cache headers to an MVC 3 app
I am using ajax via js helper in my cakephp application;
for this I am using following code.
echo $this->Js->link('test','/controller/test/', array('before'=>$this->Js->get('#loading')->effect('fadeIn'),'success'=>$this->Js->get('#loading')->effect('fadeOut'),'update'=>'#mydiv'));
It is working fine.
But when I am using this code on view page,which is rendered by ajax, it i not working.
when i check the page source i found that script for this view is not added in the buffered script.
I guess buffered script is created when the page is load.In my case when page is loaded specific content is not loaded so script for this layout is not added in the buffered script.
Please guide me is there any other method by which i can do this or i have to do it by custom jquery or another method.
You should use evalScripts option in your Ajax Link. Here is the code:
echo $this->Js->link('test','/controller/test/', array('before'=>$this->Js->get('#loading')->effect('fadeIn'),'success'=>$this->Js->get('#loading')->effect('fadeOut'),'update'=>'#mydiv', 'evalScripts' => true));
And at the bottom of your Ajax view file. Be sure to include:
<?php echo $this->Js->writeBuffer();?>