Angular: Cannot find a differ supporting object ‘[object Object]’

I think that the object you received in your response payload isn’t an array. Perhaps the array you want to iterate is contained into an attribute. You should check the structure of the received data… You could try something like that: getusers() { this.http.get(`https://api.github.com/search/users?q=${this.input1.value}`) .map(response => response.json().items) // <—— .subscribe( data => this.users = data, … Read more

Angular 2 – Routing – CanActivate work with Observable

You should upgrade “@angular/router” to the latest . e.g.”3.0.0-alpha.8″ modify AuthGuard.ts @Injectable() export class AuthGuard implements CanActivate { constructor(private loginService: LoginService, private router: Router) {} canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) { return this.loginService .isLoggedIn() .map((e) => { if (e) { return true; } }) .catch(() => { this.router.navigate([‘/login’]); return Observable.of(false); }); } } If you have … Read more

Angular2: How to load data before rendering the component?

update If you use the router you can use lifecycle hooks or resolvers to delay navigation until the data arrived. https://angular.io/guide/router#milestone-5-route-guards To load data before the initial rendering of the root component APP_INITIALIZER can be used How to pass parameters rendered from backend to angular2 bootstrap method original When console.log(this.ev) is executed after this.fetchEvent();, this … Read more

File Upload In Angular?

Angular 2 provides good support for uploading files. No third party library is required. <input type=”file” (change)=”fileChange($event)” placeholder=”Upload file” accept=”.pdf,.doc,.docx”> fileChange(event) { let fileList: FileList = event.target.files; if(fileList.length > 0) { let file: File = fileList[0]; let formData:FormData = new FormData(); formData.append(‘uploadFile’, file, file.name); let headers = new Headers(); /** In Angular 5, including the … Read more

Difference between HttpModule and HttpClientModule

Use the HttpClient class from HttpClientModule if you’re using Angular 4.3.x and above: import { HttpClientModule } from ‘@angular/common/http’; @NgModule({ imports: [ BrowserModule, HttpClientModule ], … class MyService() { constructor(http: HttpClient) {…} It’s an upgraded version of http from @angular/http module with the following improvements: Interceptors allow middleware logic to be inserted into the pipeline … Read more

Is it necessary to unsubscribe from observables created by Http methods?

So the answer is no, you don’t. Ng2 will clean it up itself. The Http service source, from Angular’s Http XHR backend source: Notice how it runs the complete() after getting the result. This means it actually unsubscribes on completion. So you don’t need to do it yourself. Here is a test to validate: fetchFilms() … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)