Skip to main content

Posts

Angular 2: Resolve querylist?

i currently create a angular 2 app, but i ran into problems with QueryList. How do i manage to get values out of it? I get the querylist with: @ViewChildren('setSlider') setSliders: QueryList ; This part works fine so far. Now i got this object: QueryList {_dirty: false, _results: Array[4], _emitter: EventEmitter} And now.. i just want to get the second result from it. For Example: setSliders[0] ---> dont work. Whats the best way to do that? thanks a lot :) Solved There are a few ways to do so. Check out API docs on Angular2 site: https://angular.io/docs/ts/latest/api/core/index/QueryList-class.html The simplest way: let secondSlide = this.setSliders.toArray()[2] You can use this too. ngAfterViewInit() { console.log(this.setSliders.toArray()); this.setSliders.changes.subscribe(val => console.log(this.setSliders.toArray()); } try using the map method: this.setSliders.map( slider => console.log(...
Recent posts

Payload gets lost during CORS PUT request

I have a webpacked client application running on localhost:8080 and an Silex PHP application running with apache on localhost:80 I try to send a PUT request with axios on the client to the silex application with a request payload. But somehow in the silex application I see no payload, the request parameters bag is empty. This is my vHost CORS config: Header always set Access-Control-Allow-Origin "http://localhost:8080" Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" Header always set Access-Control-Max-Age "1000" Header always set Access-Control-Allow-Headers "x-requested-with, x-requested-by, Content-Type, origin, authorization, accept, client-security-token" # Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request. RewriteEngine On RewriteCond %{REQUEST_METHOD} OPTIONS RewriteRule ^(.*)$ $1 [R=200,L] And these are the request and response headers. I really don't know what is miss...

How to use MediaSessianCompat for Media playback?

I have spent literally a whole day trying to understand how MediaSessionCompat works and what exactly it does? How is it different from MediaPlayer or AudioManager class? But to be honest I did not find any good explanation. The only info I got was from the android docs and some codes I found on the web which, according to me are not sufficient in this case. The only helpful thing was this video by Ian Lake that I found on Youtube. But I am still not able to understand how can we use it in our app. This is another code I found by Ian Lake, and I spent quite some time on it but still I have lots of doubts. package com.example.remotecontrolclient; import android.app.Service; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.graphics.BitmapFactory; import android.media.AudioManager; import android.os.IBinder; import android.support.v4.media.MediaMetadataCompat; import android.support.v4.media.session.MediaSessionCom...

Cloud Spanner index selection criteria

How does Cloud Spanner decide which of the available secondary indices to use, or whether to use one at all? Is there documentation on how your query planner works? Solved Cloud Spanner uses a number of different heuristics to guide index selection, and they may change without warning. If you’re curious which indices a query is using, you should try EXPLAINing the query to see the plan that gets run. If you want to guarantee selection of a particular index, consider using an Index Directive .