سؤال

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.

هل كانت مفيدة؟

المحلول

<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 .

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top