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