<p dir="auto">Hi guys.<br>
I'm working in project that's support Angular 2 and I want to upload images directly to API.<br>
How could I use Angular to do similar job ?<br>
I tried using [(ng-model)] with input type file. and I get path look like <code class="notranslate">C:/fakepath/imagename.png</code>.</p>
<p dir="auto"><strong>I'm submitting a ...</strong></p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> bug report</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> feature request</li>
</ul>
<p dir="auto"><strong>Current behavior</strong></p>
<p dir="auto">In the old router, the new router and the very new router querystring parameters always are accessible as <code class="notranslate">{[k:string]:string}</code>. To pass an array of values via the querystring we have to rely on encoding within the application to serialize and then deserialize the array. We <em>should</em> be able to simply rely on existing URL standard behavior.</p>
<p dir="auto">Adding to my frustration, there is already a class, <code class="notranslate">URLSearchParams</code> that fully models the querystring but seems unused when retrieving url search params from the router.<br>
<a href="https://angular.io/docs/ts/latest/api/http/URLSearchParams-class.html" rel="nofollow">https://angular.io/docs/ts/latest/api/http/URLSearchParams-class.html</a></p>
<p dir="auto"><strong>Expected/desired behavior</strong></p>
<p dir="auto">When retrieving data parsed from a querystring it should be presented either in a datastructure that supports the standard or in a class that models it properly.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const q: Observable&lt;URLSearchParams&gt; = r.routerState.queryParams;"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">q</span>: <span class="pl-smi">Observable</span><span class="pl-kos">&lt;</span><span class="pl-smi">URLSearchParams</span><span class="pl-kos">&gt;</span> <span class="pl-c1">=</span> <span class="pl-s1">r</span><span class="pl-kos">.</span><span class="pl-c1">routerState</span><span class="pl-kos">.</span><span class="pl-c1">queryParams</span><span class="pl-kos">;</span></pre></div>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const q: Observable&lt;{[k:string]:string[]}&gt; = r.routerState.queryParams;"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">q</span>: <span class="pl-smi">Observable</span><span class="pl-kos">&lt;</span><span class="pl-kos">{</span><span class="pl-kos">[</span><span class="pl-s1">k</span>:<span class="pl-smi">string</span><span class="pl-kos">]</span>:<span class="pl-smi">string</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">}</span><span class="pl-kos">&gt;</span> <span class="pl-c1">=</span> <span class="pl-s1">r</span><span class="pl-kos">.</span><span class="pl-c1">routerState</span><span class="pl-kos">.</span><span class="pl-c1">queryParams</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">My vote is for the URLSearchParams version of course.</p>