首页 \ 问答 \ Angular绑定服务属性到控制器范围(Angular bind service property to a controller scope)

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
更新时间:2022-03-29 18:03

最满意答案

也许这有帮助。 我不知道底层的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:

相关问答

更多
  • spring
  • 直接取就OK. List goodsList = restTemplate.getForObject(url, List.class); 参考: http : / / thekspace.com/home/ component/content/article/57-restful-clients-in-spring-3.html
  • 也许这有帮助。 我不知道底层的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 ...
  • 尝试这样的事情 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( ...
  • 那是对的。 托管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的所有者/维 ...
  • 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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)