Hi! I also started to learn angular 2. I did get method, get method with 
paging and post, but I have problem with edit and delete. Do you have 
github so I  can follow your tutorial for this? @FrancoisGreen
Thanks!

On Tuesday, October 27, 2015 at 10:42:27 PM UTC+1, Francois Green wrote:
>
> I'm trying to learn Angular 2 by creating a simple app that talks to a 
> RESTful service.  The GET request works, but not the POST.  There are no 
> errors on either the front-end or the back-end.  I'm assuming that I've 
> done something wrong, but it's hard to tell without an error message.
>
> import {Component, View, bootstrap, NgFor, FORM_DIRECTIVES, Inject} from 
> 'angular2/angular2';
> import {HTTP_PROVIDERS, Http} from 'angular2/http';
>
> class Comment {
>   author: string;
>   text: string;
>   constructor(author: string, text: string) {
>     this.author = author;
>     this.text = text;
>   }
> }
>
> @Component({
>     selector: 'my-app',
>     providers: [HTTP_PROVIDERS],
> })
>
> @View({
>   templateUrl: './app/app.html',
>   directives: [NgFor, FORM_DIRECTIVES]
> })
>
> class AppComponent {
>   comments: Comment[];
>   comment: Comment;
>
>   constructor(@Inject(Http) private http: Http) {
>     this.listAll();
>   }
>
>   listAll() {//This works!
>     this.http.get('http://localhost:4567/api/comments')
>         .subscribe(res => {
>           this.comments = res.json();
>         });
>   }
>
>   addComment(author, text) {//Nothing happens and no errors.
>     let comment = new Comment(author.value, text.value);
>     this.http.post('http://localhost:4567/api/comments', 
> JSON.stringify(comment));
>     //this.comments.push(comment);//If uncommented, valid data is pushed into 
> the array.  So the inputs work.
>     author.value = '';
>     text.value = '';
>   }
> }
>
> bootstrap(AppComponent);
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to