angular


Angular 2 RxJS Observable not loading


my web application breaks (won't load) when I use 'new Observable()' anywhere in a method or otherwise.
Angular version 2.1.0
RxJs 5.0.0-beta.12
These are my imports in the .ts-file:
import { Injectable } from '#angular/core';
import { DSUnit } from '../model/dsunit';
import { Headers, Http, Response } from '#angular/http';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import 'rxjs/add/observable/throw';
import 'rxjs/Rx';
import { DSCategory } from './../model/dscategory';
import { Observable } from 'rxjs';
When I have this piece of code it breaks:
private handleError(error: any) : Observable<any> {
let errMsg = "argh";
return new Observable(); // <-- "offending" code
}
with this error on the console of Chrome:
(SystemJS) XHR error (404 Not Found) loading http://localhost:3000/node_modules/rxjs(…)
And when I remove the offending line, and have this instead:
private handleError(error: any) : Observable<any> {
let errMsg = "argh";
return null; // <-- "works"
}
my web application loads with no errors.. of course it breaks when the 'catch'-statement tries to handle an error, but that will work once I get past the hurdle with
"new Observable()"
Any ideas, anyone?
You could try this:
Observable.of(errMsg);
or
Observable.throw(errMsg);
depending on the caller.
Damn it... the 'auto import' in Visual Studio Code had messed up my import.
When I import '{Observable}' it should not be
import {Observable} from 'rxjs'
it should be
import {Observable} from 'rxjs/Rx'

Related Links

Add polyfill code in Angular 2
Bootstrap different app modules in Angular with angular-cli
resource interrupted as script but transfered with MIME type text/plain;
Erron while running angular-cli project in windows when created form ubuntu
Angular 2 Testing a component with an observable without mocking
Angular 2: Singleton Services - Properties not remembered?
Ionic serve show this error Ionic2
“Expression has changed after it was checked” when using two instances of the same component
Inter Component Event Binding In Angular 2
Angular 2 identity method
Creating md-cards as links in Angular 2 Material
How to add angular 2 attributes inside a variable in angular 2 typescript class
Data transformation in Class vs Reducer (ngrx/redux)
Firebase Google OAuth 2.0 returns auth/network-request-failed in Angular 2 SPA
Angular 2 http.get request performed multiple time
Angular2 - http.get not calling the webpi

Categories

HOME
excel
parsing
datatables
arduino
amazon-dynamodb
automation
data-warehouse
zurb-foundation
slack
bootstrap-datepicker
q-learning
webserver
ais
visual-foxpro
worksheet-function
jasperserver
ieee
vbulletin
sorm
interaction
log4net
fontforge
adodb-php
esapi
accurev
nlog
tv
touch
coap
cropper
polymer-starter-kit
android-logcat
ggiraph
puma
sharethis
netbanx-api
angular-daterangepicker
regedit
cachemanager
nerdtree
enzyme
multibox
ssas-tabular
audiounit
exports-loader
jquery-ui-widget-factory
bisonc++
on-screen-keyboard
fixed
istanbul
ember-cli-mirage
sonarqube-4.5
unicorn
video-recording
smf
client-side
dotpeek
iis-8.5
openoffice-writer
little-endian
data-connections
kdiff3
sos
xcode4
togglz
zodb
traffic-simulation
zurb-foundation-5
supercsv
tstringgrid
bitarray
xamarin-forms
elasticsearch-marvel
setlocale
wunderlist
lastaccesstime
orchardcms-1.6
arbitrary-precision
appcompat-v7-r22.1
mux
stackato
bonsaijs
iron
complete.ly
microsoft-search-server
dynamic-html
stubs
tiles2
android.mk
mysql-5.0
lytebox
grit
clang-complete
html-validation
crashrpt
cck
dynamic-css
white-box-testing
orbited
pdc2008

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App