What is the best way to make a HTML fallback via Angular?
I need something like this:
<span>{{angularText}} plain text</span>
The plain text would be a "backup" (perhaps generated by the server), in case the user doesn't have JavaScript enabled. Of course, if the user has JavaScript enabled, then I obviously don't want both to show.
What is the best way to make a HTML fallback via Angular?
I need something like this:
<span>{{angularText}} plain text</span>
The plain text would be a "backup" (perhaps generated by the server), in case the user doesn't have JavaScript enabled. Of course, if the user has JavaScript enabled, then I obviously don't want both to show.
Share Improve this question edited May 13, 2014 at 22:12 inf3rno 26.2k13 gold badges121 silver badges206 bronze badges asked May 13, 2014 at 21:34 user3634330user3634330 431 silver badge2 bronze badges 6- 2 To be honest, if you're using Angular, you're probably already making the assumption that the user has JS enabled. – Alexis King Commented May 13, 2014 at 21:36
- Do you genuinely have a case of users that have no ability to run Javascript? – Ishan Chatterjee Commented May 13, 2014 at 21:36
- 1 Go to a angular demo page, turn JS off and you'll see what happens. (hint: probably nothing, depending on the page. But you'll definitely see `{{foo}}`` all over the place.) – nietonfir Commented May 13, 2014 at 21:37
- Actually you won't see anything like that: angularjs It has a HTML fallback. – inf3rno Commented May 13, 2014 at 22:05
- 1 It is not so much about the ability, but the will to use JavaScript, actually. JavaScript is the base for the majority of XSS attacks. With JavaScript enabled, browser tracking bees far more powerful, also when using anonymity systems like Tor, JavaScript can be used to find your actual IP address and break your anonymity. In my oppinion, it is a good idea to offer your concerned users at least read access without requiring JavaScript. – aef Commented Feb 10, 2015 at 11:26
2 Answers
Reset to default 12<span ng-bind="angularText">Default text from server</span>
?
But like the others have mentioned, why use Angular to create an app if there's a slight chance some of the intended users have JS disabled?
I suggest adding this to your site as well:
<noscript>
You do not have JS enabled. Since this is an Angular based website, it won't do jack for you :-)
</noscript>
Inside index.html:
<noscript>
<h1>Your title</h1>
<div style="somestyles...">
Your content
</div>
</noscript>
If one wishes he/she can keep a skeleton of what the site supposed to have looked if js was enabled and then a request message inside to enable javascript .