Is there typescript definition for DOM nativeElement?
You need to cast. Because of the multi-platform strategy, they didn’t specify a specific type for nativeElement: (myComponentFixture.nativeElement as HTMLElement)….
You need to cast. Because of the multi-platform strategy, they didn’t specify a specific type for nativeElement: (myComponentFixture.nativeElement as HTMLElement)….
You are using the same variable “err” in both outer and inner callbacks, which is prevented by tslint. If you want to use the same variable then “no-shadowed-variable”: false, otherwise do as below. fs.readdir(fileUrl, (readDirError, files) => { fs.readFile(path.join(fileUrl, files[0]), function (err, data) { if (!err) { res.send(data); } }); });
I encountered the same problem and found the solution: Open angular.json file; In every app configuration set: “stylePreprocessorOptions”: { “includePaths”: [ “./node_modules” ] } remove ~ in every import;
The @ symbol you are referring to is called decorator. Decorators provide a way to add both annotations and a meta-programming syntax for class declarations and members. Basically when you are doing @component you are telling compiler that the class is a angular2 component with the metadata passed as an argument. for eg. @Component({ moduleId: … Read more
Don’t call subscribe() in your service and instead let the route subscribe. Change return this.searchService.searchFields().subscribe(fields => { to import ‘rxjs/add/operator/first’ // in imports return this.searchService.searchFields().map(fields => { … }).first(); This way an Observable is returned instead of a Subscription (which is returned by subscribe()). Currently the router waits for the observable to close. You can … Read more
That exists with slightly different syntax: <template ngFor let-element [ngForOf]=”data” let-i=”index”> <tr>…</tr> //row 1 <tr>…</tr> //row 2 </template> or <ng-container *ngFor=”let element of data let i=index”> <tr>…</tr> //row 1 <tr>…</tr> //row 2 </ng-container> update for >= 4.0.0 <template> was changed to <ng-template> <ng-template ngFor let-element [ngForOf]=”data” let-i=”index”> <tr>…</tr> //row 1 <tr>…</tr> //row 2 </ng-template>
I would use a subject to keep everything reactive. In your template html listen to change events and emit a new value to the subject. <searchBar (change)=”search$.next($event.target.value)” /> then in your component: this.subscription = this.search$.pipe( debounceTime(800), distinctUntilChanged(), switchMap(searchText=>http.post(‘api_link’, {searchText}) }).subscribe(response=>{ this.response = response. }); The switchMap will cancel any HTTP request that hasn’t completed if … Read more
As you are new to TypeScript. I still suggest you to follow angular.io docs for 5 min startup. That has specific instruction and quite well explained to get started with it. Angular2 5 min quickstart page @ angular.io. What you need to have basically to start: Node.js with npm package manager. Typescript with compiler. A … Read more
When you are building the application using ng build, you should use the following flag: –outputHashing=all This is to enable cache-busting. This adds a hash to every single built file such that the browser is forced to load the latest version whenever you have uploaded a new version to your servers. Threfore, one way to … Read more
There is no use of Bootstrap() in Ionic2, only use of @App to declare your app. You still need to declare your service in your @Page component. Create your service import {Injectable} from “angular2/core”; import {Http} from “angular2/http”; @Injectable() export class DataService { constructor(http: Http) { this.http = http; this.data = null; } retrieveData() { … Read more