首页 \ 问答 \ 来自变量/属性的ui-sref(ui-sref from variable / attribute)

来自变量/属性的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-routerhttps://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
更新时间:2022-06-02 06:06

最满意答案

我肯定会考虑首先使用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 ...
  • 您需要将它添加到您的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 ...
  • (因为这已被拒绝,所以无法帮助;我猜你的问题不适用于逻辑或最佳实践) 基本上你不能简单地改变它,因为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 ...
  • 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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。