首页 \ 问答 \ AngularJS资源依赖项(AngularJS resource dependencies)

AngularJS资源依赖项(AngularJS resource dependencies)

我在MVC应用程序之上使用AngularJS。 如何使我的AngularJS应用程序依赖于已加载的资源? 在这种情况下,我想确保在其他任何事情发生之前加载我的UserData。 我正在使用UI路由器,我知道我可以在各个路由上设置解析状态,但我不想将其添加到每个路由。 是否有全球性的方法来做到这一点?


I am using AngularJS on top of an MVC application. How can I make my AngularJS app depend on a resource having been loaded? In this case I want to ensure my UserData is loaded BEFORE anything else happens. I am using UI Router and I know I can set resolve states on individual routes but I dont want to have to add this to every route. Is there a global way to do this?


原文:https://stackoverflow.com/questions/33868901
更新时间:2022-05-21 08:05

最满意答案

这与私人与否无关。 有什么相关的是这样的:

内存一致性效果:在将一个Runnable对象提交给Executor之前,在一个线程中的操作发生 - 在其执行开始之前,可能在另一个线程中。

来自Executor文档 。 这意味着无论您在submit调用之前做什么,都可以在可运行的应用程序中看到。 你甚至可以在构造执行器之后执行它,在这种特殊情况下,执行线程实际上何时启动并不重要,因为submit方法本身提供了非常有力的保证。

这是使java.util.concurrent包非常有用的特性之一。


It's irrelevant whether it's private or not. What's relevant is this:

Memory consistency effects: Actions in a thread prior to submitting a Runnable object to an Executor happen-before its execution begins, perhaps in another thread.

From Executor docs. Which means that whatever you do before the call to submit is visible in the runnable. You could even do it after constructing the executor, and in this particular case it doesn't even matter when the executing thread actually starts because the submit method provides a very strong guarantee by itself.

This is one of the features that make java.util.concurrent package very useful.

相关问答

更多
  • 这与私人与否无关。 有什么相关的是这样的: 内存一致性效果:在将一个Runnable对象提交给Executor之前,在一个线程中的操作发生 - 在其执行开始之前,可能在另一个线程中。 来自Executor文档 。 这意味着无论您在submit调用之前做什么,都可以在可运行的应用程序中看到。 你甚至可以在构造执行器之后执行它,在这种特殊情况下,执行线程实际上何时启动并不重要,因为submit方法本身提供了非常有力的保证。 这是使java.util.concurrent包非常有用的特性之一。 It's irre ...
  • 参考this 最好的方法如下,因为你需要所有变量的共同价值 a= b= c = d = 'foo' 对于不同的价值你可以做 a, b, c, d = 'foo1', 'foo2', 'foo3', 'foo4' Ref this Best way to do it as follow as you need common value to all your variables a= b= c = d = 'foo' for different value you can do a, b, c, d = ...
  • 我想他们希望通过具有非线性访问层次结构来避免增加的复杂性。 你应该可以控制你的包,所以不要在这里调用这些保护的方法。 (顺便说一下, protected与sub-class and package不完全相同,因为非静态保护方法(如果不在同一个包中)不能在声明类的任意对象上调用,而只能对对象代码所在的子类(您可以在Object.clone()上看到这一点,只能由被克隆对象的类调用)。) I suppose they want to avoid the added complexity by having a ...
  • 它将保持受保护,这与C ++不同,后者取决于继承的类型(公共,受保护或私有),它保持不变。 C ++允许这种继承的主要原因是它支持多重继承。 但是,Java不支持它。 因此,它只是通过将访问级别保持为超类来简化它。 It would remain protected unlike in C++ where depending on the type of inheritance (public, protected or private) it remains the same. The main reas ...
  • 这是倒退的: public House(int _year,int _size){ _year = year; _size = size; } 应该: public House(int _year,int _size){ year = _year; size = _size; } 或者更好的是: public House(int year,int size){ this.year = year; this.size = size; } This is b ...
  • 它是可见的,你只需要让它成为final : final List list = new ArrayList(); 更一般地说,如果这些变量被声明为final ,则匿名类(如您的CallBack )只能访问该类外部的局部变量。 It is visible, you just need to make it final: final List list = new ArrayList(); More generally, an anonymou ...
  • 在你的代码中,所有者在if条件的范围内被本地声明。 尝试此代码修改 User owner = null; if ((owner = (User)search.getOwner()) instanceof User && owner.getId() != null) { searchQuery.append("owner_id = :ownerId AND "); queryMap.put("ownerId", owner.getId()); } In Your co ...
  • 区别在于您先进行乘法还是先进行除法 - 以及这些操作的类型。 这个: (x - 32) * 5 / 9 相当于: ((x - 32) * 5) / 9 因此,如果x的类型是double ,那么x - 32的类型是double ,所以5被提升为double ,乘法是double算术,得到double结果,然后除法也是 double算术。 即使x是整数类型,你首先进行乘法,这可能会给你一个大于9的值(在你的测试用例中),给你一个非零结果。 例如,如果x为45,则x-32为13, (x - 32) * 5为6 ...
  • 所以,这里有一些关于浮点运算如何在Java中工作的规则: 在程序中编写浮点文字时,Java编译器会使用Double.parseDouble(String)将该值解析为double 。 Double.parseDouble(Double.toString(x))等于x ,但NaN除外,这很奇怪。 Double.toString(Double.parseDouble(string))可能与string不同,因为double精度有限。 例如, Double.toString(Double.parseDouble( ...
  • 现代Java版本(从Java 7开始)处理这种情况的惯用方式是使用try-with-resource块来处理所有难以理解的关闭“逻辑”。 您仍然需要捕获异常或向上传播它,但这是一个相对较小的问题。 考虑以下: public static boolean writeToFile(String path, String fname) { File file = new File(path, fname); try (FileOutputStream stream = new FileOutput ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)