在尝试捕获承诺拒绝时,我在IE8上遇到了一个奇怪的错误(基本ngResource
调用返回的承诺):
此代码使用.then(success, fail)
语法:
promise.then(function(response) {
// success
},
function(response) {
// error
});
Run Code Online (Sandbox Code Playgroud)
但这个失败的.then(success).catch(fail)
语法:
promise.then(function(response) {
// success
})
.catch(function(response) {
// error
});
Run Code Online (Sandbox Code Playgroud)
并且指向该.catch()
行的IE错误是:
预期的标识符
难道我做错了什么 ?有人重现了吗?或者由于受限制的关键字,它是一个常见的IE8?
谢谢
internet-explorer internet-explorer-8 promise angularjs angular-promise
我有半透明主题的活动:
android:theme="@android:style/Theme.Translucent.NoTitleBar"
Run Code Online (Sandbox Code Playgroud)
此问题也可以通过以下主题重现:
<style name="MyTheme" parent="@android:style/Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackground">@null</item>
</style>
Run Code Online (Sandbox Code Playgroud)
此活动在启动时加载并保存在内存中(当我开始此活动时,我将该FLAG_ACTIVITY_REORDER_TO_FRONT
标志作为额外标记).
问题:当我开始此活动时(从菜单中),活动没有显示,没有任何反应.但是:如果我删除半透明主题:一切正常,活动就会回到正面.
是的onNewIntent()被调用.
如果我按回半透明活动是下面的那个!但它需要成为顶级.
一个例子是
A(半透明活动)BC
堆栈:A
一个startActivity(B)
堆栈:A,B
B startActivity(C)
堆栈:A,B,C
c startActivity(A)//带有标志FLAG_ACTIVITY_REORDER_TO_FRONT
堆栈应为:B,C,A
但是A永远不会被带到前面,尽管它的onNewIntent()被调用.
有任何想法吗?
旁注
有趣的未回答的问题:http://groups.google.com/group/android-developers/browse_thread/thread/269c67f6b39cfe45?pli = 1
android:launchMode
的singleTask
或singleInstance
不希望被使用.这些更改了backstack并将活动移动到自己的堆栈中.因此我们不再有A,B,C了.
singleTask和singleInstance - 不适合大多数应用程序,因为它们会导致用户可能不熟悉的交互模型,并且与大多数其他应用程序非常不同.
http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
想要直观表示launchModes的任何人都可以尝试以下应用:https://play.google.com/store/apps/details? id = com.novoda.demos.activitylaunchmode
我过去只shareReplay
调用一次(如缓存)一个网络服务来检索一些信息:
在我的服务中:
getProfile(): Observable<Customer> {
return this.callWS().pipe(shareReplay(1));
}
Run Code Online (Sandbox Code Playgroud)
在多个组件中:
this.myService.getProfile().subscribe(customer => {
console.log('customer informations has been retrieved from WS :', customer);
});
Run Code Online (Sandbox Code Playgroud)
现在我想添加一个方法来强制刷新信息(只绕过 shareReplay 一次)。我尝试将我的 observable 存储在一个变量中,并在重新初始化之前将其设置为 null,但它似乎破坏了组件订阅..
有什么帮助吗?
谢谢
我的身份验证基于两件事:
我还有基于isAuthenticated()
返回Observable的authGuards (因为在页面刷新时,guard必须等待auth完成才能将用户重定向到任何地方).
问题:我无法找到一种方法来使所有async和rxjs混乱/地狱工作..目前它正在工作,但每次isAuthenticated
调用,每次都调用serverAPI auth ...我怎么能按顺序重构只调用一次服务器,所有的异步/重载东西仍然有效吗?
AuthService:
export class AuthService {
public userRole: UserBoRole;
public authState$: Observable<firebase.User>;
constructor(
private afAuth: AngularFireAuth,
private snackBar: SnackBarService,
private translate: TranslateService,
private router: Router,
private grpcService: GrpcService
) {
this.authState$ = this.afAuth.authState.pipe(
take(1),
mergeMap(user => {
if (!user) {
return of(user);
}
// User is successfully logged in,
// now we need to check if he has a correct role to access our app
// if an …
Run Code Online (Sandbox Code Playgroud) 我遇到了一个我试图实现的Iframe指令的问题.
我到目前为止:模板:
<div class="externalIframe" iframe-src="external.html"></div>
Run Code Online (Sandbox Code Playgroud)
指令:
angular.module('project.directives', [])
.directive('externalIframe', ['$rootScope', function($rootScope) {
return {
restrict: 'C',
replace: true,
transclude: true,
scope: {
src: '@iframeSrc', // the src uses the data-binding from the parent scope
},
template: '<iframe src="{{src}}" height="100%" width="100%" frameborder="0"></iframe>',
link: function(scope, elem, attrs) {
//elem.src = "dummy.html"; // not working either
}
}
}])
Run Code Online (Sandbox Code Playgroud)
问题:它触发2个HTTP请求(2个iframe加载).:
http://localhost:8000/app/{{src}}
(iframe src还没有被angular解释)http://localhost:8000/app/external.html
(iframe src一次由angular解释)我想避免无用的第一次通话..我怎么能这样做?
我尝试在模板中没有src并以编程方式在链接或编译函数中设置它,但这不会触发iframe加载.
编辑:jsFiddle使用编译方法添加了bug演示 =>你会在firebug/chrome开发面板的网络选项卡中看到两个请求:
http://fiddle.jshell.net/_display/%7B%7Bsrc%7D%7D
http://fiddle.jshell.net/_display/external.html
谢谢您的帮助
我正在尝试在用户与页面交互后立即自动播放视频。如果我之前播放视频,我显然会收到安全错误:
Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.
Run Code Online (Sandbox Code Playgroud)
这是公平的,我发现了这个错误,现在想注册一个事件,以便在用户与页面交互后立即重试播放。
=> 有这样的活动吗?
我试图在 mouseover/mousemove/touchmove/click/focus/visibilitychanged 上注册事件,但它不是最佳的,并且在一些测试后不是很可靠......
javascript ×3
angularjs ×2
rxjs ×2
typescript ×2
android ×1
angular ×1
asynchronous ×1
autoplay ×1
caching ×1
events ×1
firebase ×1
html ×1
iframe ×1
promise ×1
stack ×1
transparency ×1
video ×1