Angular绑定服务属性到控制器范围(Angular bind service property to a controller scope)
我有2个控制器使用相同的服务,第一个控制器更改服务上属性的值,我需要第二个控制器知道属性已更改为在其当前$ scope中设置新值。 我不想使用广播,是否有一种优雅的方式来做到这一点?
谢谢。
I have 2 controllers using the same service, the first controller change the value of a property on the service, I need the second controller to know the property has changed to set the new value in his current $scope. I dont want to use broadcast, is there an elegant way to do this ?
Thank you.
原文:https://stackoverflow.com/questions/32510495
最满意答案
也许这有帮助。 我不知道底层的http调用是通过HttpUrlConnection进行的,但将sun.net.http.allowRestrictedHeaders设置为true可能值得尝试。
看到:
Perhaps this helps. I don't know if the underlying http call is made through HttpUrlConnection, but setting sun.net.http.allowRestrictedHeaders to true might be worth trying.
See:
相关问答
更多-
是不是有一款什么手机软件,可以很自然的拉长腿部?不是美图秀秀,有知道的不?[2022-10-20]
spring -
春天的英语怎么读?[2022-05-21]
spring -
Spring RestTemplate 使用问题。[2022-04-19]
直接取就OK. List goodsList = restTemplate.getForObject(url, List.class); 参考: http : / / thekspace.com/home/ component/content/article/57-restful-clients-in-spring-3.html -
为Spring RestTemplate设置“Host”标头不起作用(Setting “Host” header for Spring RestTemplate doesn't work)[2023-10-24]
也许这有帮助。 我不知道底层的http调用是通过HttpUrlConnection进行的,但将sun.net.http.allowRestrictedHeaders设置为true可能值得尝试。 看到: 我可以覆盖使用java的HttpUrlConnection类的Host头吗? 如何在HttpURLConnection中覆盖http-header“Host”? Perhaps this helps. I don't know if the underlying http call is made throu ... -
我终于得到了这个工作。 我认为我们的项目有两个不同版本的commons-httpclient jar的事实没有帮助。 一旦我排序,我发现你可以做两件事情... 在代码中,您可以放入以下内容: HttpComponentsClientHttpRequestFactory rf = (HttpComponentsClientHttpRequestFactory) restTemplate.getRequestFactory(); rf.setReadTimeout(1 * 1000); rf.setCo ...
-
不,RestTemplate将继续存在。 您不必使用WebClient替换它。 其中一个主要区别是RestTemplate是同步和阻塞的。 即当您进行休息电话时,您需要等到响应回复才能继续。 但WebClient与此完全相反。 来电者不必等到响应回来。 相反,他会在有回应时收到通知。 如果你需要这样的功能,那么你需要用WebClient替换你的Resttemplate。 您可以使用.block()在webclient中实现Rest模板,如同步处理。 但另一种方式是不可能的。 No, RestTemplate ...
-
在Spring RestTemplate GET调用上设置自定义标题(Setting custom header on Spring RestTemplate GET call)[2022-04-07]
尝试这样的事情 HttpHeaders createHeaders(String username, String password){ 返回新的HttpHeaders(){{ String auth = username +“:”+ password; byte [] encodedAuth = Base64.encodeBase64( auth.getBytes(Charset.forName(“US-ASCII”))); String authHeader =“Basic”+ new String( ... -
Spring RestTemplate SSL(Spring RestTemplate SSL)[2022-04-17]
那是对的。 托管RESTful端点的服务器负责提供SSL。 SSL握手发生在客户端传递有效负载之前。 在SSL握手期间,服务器与客户共享其公共非对称密钥,并保留其不与任何人共享的私有非对称密钥。 这些密钥用于建立会话期间用于加密所有通信(IP地址除外)的单个会话密钥。 您可以使用网络协议分析器(如Wireshark)来验证这一点,该协议分析器允许您检查遍历网络的数据包。 运行Wireshark并捕获客户端发送到端点的数据包,您应该看到它们已加密。 That is correct. The server ho ... -
检查响应显示请求通过Cloudflare,并且响应包含以下错误: 该网站的所有者(swapi.co)已根据您的浏览器签名禁用您的访问权限(3a4c8846af5169b2-ua21)。 因此,您可以欺骗并添加可接受的User-Agent标头。 例如: headers.add("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0"); 您应该联系swapi的所有者/维 ...
-
Spring restTemplate(Spring restTemplate)[2023-05-31]
RestTemplate从不管理会话,也不管理任何服务,因为它们都是无状态的。 如果要管理状态,您可以做的是第一次获取令牌,然后每次将该令牌传递给下一个服务调用。 RestTemplate never manages session, nor do any of the service because all of them are stateless. If you want to manage the state, what you can do is get the token first time ...