来自变量/属性的ui-sref(ui-sref from variable / attribute)
我正在将我的SPA从ng-route过渡到ui.router。 对于某人来说,这应该是一个快速的...
对于我的一些州,我定义了
$rootScope.nextState
和$rootscope.prevState
属性($rootscope.prevState
strings),这样我的导航栏上就可以有上一个和下一个按钮/链接。我似乎无法得到正确的链接。 我努力了:
<button ui-sref="{{prevState}}">Previous</button> <button ui-sref={{prevState}}>Previous</button> <button ui-sref="{prevState}">Previous</button> <button ui-sref="prevState">Previous</button> <button ng-href="{{$state.href(prevState)}}">Previous</button> <button ng-click="$state.go(prevState)">Previous</button>
所有上述内容
<a>
代替。全部抛出“无效状态引用”错误或不更改状态。 如何在ui-router中使用
statename
的动态属性?我尽我所能阅读并理解了文档。 类似的问题没有帮助: https : //stackoverflow.com/questions/23476296/dynamically-constructed-ui-sref-attribute-in-ui-router和https://stackoverflow.com/questions/24349731/dynamically-设定的值-的-UI-SREF-angularjs
这是一个重新发现问题的Plunker 。 它在类似于angular-ui-router-title的方法中使用resolve。 这可能是问题的时机问题......
I am transitioning my SPA from ng-route to ui.router. This should be a quick one for someone...
For some of my states, I have
$rootScope.nextState
and$rootscope.prevState
attributes defined (statename strings), so that I can have Previous and Next buttons / links on my navbar.I can't seem to get the link correct. I have tried:
<button ui-sref="{{prevState}}">Previous</button> <button ui-sref={{prevState}}>Previous</button> <button ui-sref="{prevState}">Previous</button> <button ui-sref="prevState">Previous</button> <button ng-href="{{$state.href(prevState)}}">Previous</button> <button ng-click="$state.go(prevState)">Previous</button>
All of the above with
<a>
instead.All throw an "Invalid state ref" error or don't change the state. How can you use a dynamic attribute for
statename
in ui-router?I have read and understood the docs to the best of my ability. Similar questions that haven't helped: https://stackoverflow.com/questions/23476296/dynamically-constructed-ui-sref-attribute-in-ui-router and https://stackoverflow.com/questions/24349731/dynamically-set-the-value-of-ui-sref-angularjs
Here's a Plunker recreating the problem. It uses resolve in a method similar to angular-ui-router-title. It might be the timing of things that's the issue...
原文:https://stackoverflow.com/questions/33654577
最满意答案
我肯定会考虑首先使用Amazon Cloudfront作为CND,然后根据需要进行额外的缩小。 我认为通过CND服务资产会给你带来更大的提升,而不仅仅是缩小。
此外, Expression Engine的 Assets插件具有内置的Amazon S3支持,因此可以无缝地同步您的资产。 或者,您可以定期进行
rsync
,这也很有效; 我在最后使用了s3cmd工具它运行良好(不要被他们网站的外观关闭, s3cmd非常容易使用。I'd definitely consider using Amazon Cloudfront as a CND first and then do additional minification as needed. I think that serving assets via a CND will give you bigger boost in performance than just minification.
Additionally, Assets plugin for Expression Engine has a built-in Amazon S3 support so it could make syncing your assets with seamless. Alternatively, you could
rsync
periodically, that works well too; I have used s3cmd tool in the last it works well (don't get turned off by the look of their website, s3cmd is very easy to use.
相关问答
更多-
最后(因为没有人来救我)我通过这样做实现了它: 图像/资产位于cdn.webapp.com并且通常包含在页面的HTML中。 然后Javascript将运行并设置这些图像所在的div没有高度。 这仍然允许加载图像,但不会在页面上呈现它们。 然后我找到了一个JS库( https://github.com/desandro/imagesloaded )来注册这些图像的回调,这样它就会在图像被完全下载时通知我。 In the end (and because no one came to my rescue) I ...
-
Rails 4资产 - 生产环境 - 预编译 - CDN - Opsworks(Rails 4 assets - production env - precompile - CDN - Opsworks)[2023-04-01]
您需要将它添加到您的production.rb文件(以及您希望在其中进行摘要的任何其他环境) config.assets.digest = true You need to add this to your production.rb file ( and any other environnent that you want to have digests in ) config.assets.digest = true -
尝试在Paperclip选项中设置s3_host_alias选项: options[:s3_host_alias] = "d1bfllp5zjnl7u.cloudfront.net" Try setting the s3_host_alias option in your Paperclip options: options[:s3_host_alias] = "d1bfllp5zjnl7u.cloudfront.net"
-
到目前为止,这是我们在选择CDN(Fastly)的原始主机时发现的: myapp.appspot.com :支持TLS,但要求Host HTTP标头完全是myapp.appspot.com 。 因此, Host头需要被覆盖。 ghs.googlehosted.com :不支持TLS,但接受任何Host HTTP标头,因此您可以使用任何App Engine自定义域。 更多信息在App Engine组的此线程中。 编辑:我错过了在请求中发送SNI。 现在它适用于ghs.googlehosted.com和TLS。 ...
-
我肯定会考虑首先使用Amazon Cloudfront作为CND,然后根据需要进行额外的缩小。 我认为通过CND服务资产会给你带来更大的提升,而不仅仅是缩小。 此外, Expression Engine的 Assets插件具有内置的Amazon S3支持,因此可以无缝地同步您的资产。 或者,您可以定期进行rsync ,这也很有效; 我在最后使用了s3cmd工具它运行良好(不要被他们网站的外观关闭, s3cmd非常容易使用。 I'd definitely consider using Amazon Cloud ...
-
Codeigniter与CDN(Codeigniter with CDN)[2023-06-21]
(因为这已被拒绝,所以无法帮助;我猜你的问题不适用于逻辑或最佳实践) 基本上你不能简单地改变它,因为CDN使用不同的Domain / Subdomin,命名约定和结构。 但是,你可以试试这个; 假设您的Web服务器可以使用.htaccess ,和 假设CDN将具有相同的文件夹结构和名称。 ::尝试将所有图像/资源请求重定向到CDN。 RewriteRule ([^.]+\.(jpe?g|gif|bmp|png|mp4|css|js))$ http://www.cdn-url.com/$1 [R=301,L, ... -
这应该是可行的。 您的.htaccess文件(在www根目录中)看起来像这样: RewriteCond %{HTTPS} =on RewriteRule ^(.*)$ - [env=proto:https] RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ - [env=proto:http] RewriteCond %{HTTP_HOST} ^mydomain.com/assets$ RewriteRule ([^.]+\.(jpe?g|gif|bmp|png)) ...
-
设置缓存标头将产生类似的性能AFAIK。 GAE和GCS都使用Google Edge缓存 。 GCS可能更容易管理您的静态资源,而需要重新部署到GAE来添加/删除静态资源。 其他重要说明:GCS as CDN无法通过HTTPS与自定义域一起使用。 GAE确实支持使用自定义域的HTTPS。 Setting your cache headers will result in similar performance AFAIK. Both GAE and GCS use Google Edge cache. GC ...
-
我相信您可以使用以下方式访问Sprockets助手: self.class.helpers.asset_path('application.css')或 self.class.helpers.asset_digest_path('application.css') 这两种方法都是向后访问Sprockets用于生产中指纹资产的帮助程序的方法。 那样有用吗? 基于这个 SO答案 I believe you can access the Sprockets helper using: self.class.hel ...
-
如何使用github repo像CDN服务器一样上传资产文件?(How to use github repo as like CDN server for uploading assets file?)[2022-03-09]
1.)将图像编码到base 64 ref: http : //ruby-doc.org/stdlib-2.2.0/libdoc/base64/rdoc/Base64.html 2.)对github进行API调用 ref: https : //developer.github.com/v3/repos/contents/#create-a-file 这将上传并返回您存储的图像的URL在github中,并将其存储在您的数据库中。 虽然你声明你不想使用S3,但回形针宝石使它非常精简。 1.) Encode ima ...