Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 15 15:20
    alanhg commented #1997
  • Sep 30 15:12
    bbrink68 commented #2049
  • Aug 23 13:34
    SouravKumar89 edited #2058
  • Aug 23 13:27
    SouravKumar89 opened #2058
  • Aug 22 00:04

    PatrickJS on master

    Update README.md (compare)

  • Aug 13 17:17
    ramsunvtech commented #1925
  • Aug 12 22:58
    terrancecorley commented #770
  • Aug 09 02:30
    jindovu commented #2049
  • Aug 09 02:22
    jindovu opened #2057
  • Aug 08 10:49
    krawinkelm commented #2053
  • Jul 21 14:14
    FilipLitwora commented #958
  • Jul 21 14:14
    FilipLitwora commented #958
  • Jul 21 14:14
    FilipLitwora commented #958
  • Jul 09 11:40
    Sanafan commented #1713
  • Jul 05 11:41
    hoang-innomizetech commented #2053
  • Jul 05 07:32
    Jilaba commented #1824
  • Jun 29 04:31
    Jason-Cooke synchronize #2055
  • Jun 28 14:51
    jesslilly commented #1827
  • Jun 12 18:16
    dvaldivia commented #1969
  • Jun 12 17:55
    dvaldivia commented #2049
Ben Radcliffe
@bradcliffe
Basically I have a JSON file that I just want to retrieve and load into the app for seed data, but I'm not sure how to do this. I keep getting a lot of errors with my current implementation.
import {Injectable} from 'angular2/angular2';
import {Http} from 'angular2/http';

@Injectable()
export class DataService {

  constructor(http: Http) {
    this.http = http;
    this.data = null;
    console.log('DataService constructor');
  }

  retrieveData() {
    this.http.get('../data/user.json')
    .map(res => res.json())
    .subscribe(data => {
      this.data = data;
    });
  }
}
I get Property 'http' does not exist on type 'DataService' and Property 'data' does not exist on type 'DataService', but this is modeled directly after articles I've read, and I'm not seeing them declare properties before the constructor function.
Carlos Liu
@carlosliu
@bradcliffe You have to either declare the class member http and data, or use private or public in constructor parameters.
export class DataService {
  private http: Http;

  constructor(http: Http) { this.http = http; }
}
export class DataService {

  constructor(private http: Http) { }
}
It’s a “not-so-recent” typescript change. Please read http://www.typescriptlang.org/Handbook#classes-privatepublic-modifiers .
Ben Radcliffe
@bradcliffe
Hmm.. Alright, @carlosliu, I just went with declaring members like you said. Actually did a bit of a rewrite.
import {Injectable} from 'angular2/angular2';
import {Http, Response} from 'angular2/http';

@Injectable()
export class AccountService {

  account: Object;
  http: Http;

  constructor(http: Http) {
    this.http = http;
    this.loadAccount();
  }

  loadAccount() {
    this.account = null;
    this.http.get('./api/goodstanding.json').map((res: Response) => res.json()).subscribe(res => this.account = res);
  }
}
Basically I want to instantiate the account across my app, so do I just need to inject this service into the root component's constructor?
Ben Radcliffe
@bradcliffe
I think the loadAccount() method should actually be returning the account object? Is that right? So that I could inside my root component's constructor have something like:
constructor(public account: AccountService) {
    this.account = account.loadAccount();
  }
Ben Radcliffe
@bradcliffe
Is that right? Am I instantiating the account for the app by returning the object from the AccountService? Or is this the wrong way to do things? It actually seems to be just returning an observable. I just want a plain object to read properties from to render into templates.
Matthew de Nobrega
@matthewdenobrega

@bradcliffe for me the easiest way to manage loading data from an api is to have the AccountService return an observable, and assign the value the Observable resolves to in the controller.

accountService.loadAccount().subscribe(res => this.account = res);
`

So the services make Observables of data available, and other components can subscribe to those Observables and do whatever they need to with the data coming from them. I know a lot of people liked the way you could assign a promise to a variable in Angular.js and it would take the value and update the DOM when the promise resolved, but that sort of 'looks like synchronous code but isn't' hides a lot of complexity - having services expose Observables of data is more flexible (you can do all the RXjs magic on the streams) and easier to reason about, at the cost of a bit of a learning curve.

Has anyone here used immutable data with Typescript? Immutable.js is fine for untyped data (arrays, hashmaps), but I can't see a way to declare typed immutable objects in Typescript. My understanding is the const keyword blocks updating an Object reference, but doesn't block updating the values of members. Seems a pity to have to decide between immutability and typing, so if anyone has a working approach to share that would be great.
binarious
@binarious

How do I need to include 3rd party angular2 modules written in TypeScript? I tried it with ng2-bootstrap the following way:

import {pagination} from 'ng2-bootstrap/ng2-bootstrap';

This results in:

Module parse failed: /Users/xxx/projects/xxx/node_modules/ng2-bootstrap/ng2-bootstrap.ts Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| export * from  './components/accordion/accordion';
| export * from  './components/alert/alert';
| export * from  './components/buttons/button-radio';
 @ ./src/components/delivery/list.ts 26:22-60
PatrickJS [tipe.io]
@gdi2290
@binarious can you check out this Pull-Request
https://github.com/AngularClass/angular2-webpack-starter/pull/127/files
binarious
@binarious
@gdi2290 Thank you!
PatrickJS [tipe.io]
@gdi2290
np, for faster replies you can join our slack
http://angularclass.com/member-join/
binarious
@binarious
Joined via that form. Do you have some complex ng2 form examples at Angular Class?
PatrickJS [tipe.io]
@gdi2290
@binarious we don’t but we take requests so I can make one. just send me a gist with requirements for the example you want to see
binarious
@binarious
@gdi2290 I'll talk to my team to gather the requirements tomorrow. What's the pricing?
PatrickJS [tipe.io]
@gdi2290
depending on the requirements it’s free since we would write a blog post about it
binarious
@binarious
allright, thanks for the input.
PatrickJS [tipe.io]
@gdi2290
np
Zarko Susnjar
@zarkosusnjar

Hi guys, I'm wondering is this the right way of sharing data retrieved from HTTP between components

http://plnkr.co/edit/qktNCz8Aup6TizN00vnp?p=preview

  <personeditorA [person]="person" > </personeditorA>

      <personeditorB [person]="person" > </personeditorB>

      <personeditorC [person]="person" > </personeditorC>

      <personeditorD [person]="person" > </personeditorD>

Basically, making one empty object, and fill it with data in parent component after data arrives, bind this variable to child components.

binarious
@binarious

@zarkosusnjar Wondering the same, because I'm doing this, too. But I also listen to person-change in the sub-components to notify the parent of changes that aren't directly caused by input fields:

<personeditorA [(person)]="person" > </personeditorA>

I'm joining AngularClass's Slack right now to ask for a complex form example. Maybe this gets covered, too, if they're interested.

gm
@gmchaturvedi1
hello friends
i have install angular-webpack-starter but my css files not working how to add those fiules
gm
@gmchaturvedi1
hello friend
can anyone help me to work css with this boilerplate
Netanel Basal
@NetanelBasal
This message was deleted
This message was deleted
Zarko Susnjar
@zarkosusnjar

Hi guys,

what's the best way to grab values in hidden inputs set by server and keep in application somewhere to use in services later for HTTP calls

       <input type="hidden" name="userId" value="123456789">

Thanks in advance!

Zahadi Eslicho
@panKt

Hi, there is config of routes

@RouteConfig(ROUTES)
...

How can I find out which one of those routes is currently active?

Yaroslav Yakovlev
@yaroslavya
Hi, I just made a lone of AngularClass/angular2-webpack-starter, made npm install and npm test gives me
Module not found: Error: Cannot resolve module 'angular2/test'
actually I got this chats page by googling it
PatrickJS [tipe.io]
@gdi2290
@yaroslavya thanks for reporting I’ll fix it now
Yaroslav Yakovlev
@yaroslavya
@gdi2290 wow, thats really a fast reply :-) can I be of a help? give you the log, open the issue on github or anything?
PatrickJS [tipe.io]
@gdi2290
@yaroslavya can you open an issue in the repo
Yaroslav Yakovlev
@yaroslavya
@gdi2290 in process of doing this
PatrickJS [tipe.io]
@gdi2290
thanks
Yaroslav Yakovlev
@yaroslavya
@gdi2290 heres the issue: AngularClass/angular2-webpack-starter#142
@gdi2290 let me know if you need more details or anything.
Yaroslav Yakovlev
@yaroslavya
@gdi2290 that was fast! but now I have another error: Error: Cannot find module "rxjs/operators/toPromise"
at C:/programming/playground/ngt/angular2-webpack-starter/spec.bundle.js:23246 <- webpack:///~/angular2/src/facade/async.js:13:0
it looks like its related
PatrickJS [tipe.io]
@gdi2290
@yaroslavya can you pull latest
Yaroslav Yakovlev
@yaroslavya
sure, will clone and start over
but I got the latest changes in karma and spec.bundle.js
PatrickJS [tipe.io]
@gdi2290
I changed it to spec-bundle.js npw
now**