angular

Getting content of dynamic templates in component

大城市里の小女人 提交于 2021-02-11 05:16:59
问题 Here is the template: <button (click)="loadTemplate()">Load Template</button> <ng-template #tmpl let-name> <h2>hello</h2> <h2>{{name}}</h2> </ng-template> Here is the component: export class AppComponent { @ViewChild("tmpl", { read: TemplateRef, static: false }) tmpl: TemplateRef<any>; loadTemplate() { const viewRef = this.tmpl.createEmbeddedView({ $implicit: "angular" }) alert('content for static h2 element: ' + viewRef.rootNodes[0].textContent) alert('content for dynamic h2 element: ' +

Getting content of dynamic templates in component

人走茶凉 提交于 2021-02-11 05:14:04
问题 Here is the template: <button (click)="loadTemplate()">Load Template</button> <ng-template #tmpl let-name> <h2>hello</h2> <h2>{{name}}</h2> </ng-template> Here is the component: export class AppComponent { @ViewChild("tmpl", { read: TemplateRef, static: false }) tmpl: TemplateRef<any>; loadTemplate() { const viewRef = this.tmpl.createEmbeddedView({ $implicit: "angular" }) alert('content for static h2 element: ' + viewRef.rootNodes[0].textContent) alert('content for dynamic h2 element: ' +

Getting content of dynamic templates in component

给你一囗甜甜゛ 提交于 2021-02-11 05:10:10
问题 Here is the template: <button (click)="loadTemplate()">Load Template</button> <ng-template #tmpl let-name> <h2>hello</h2> <h2>{{name}}</h2> </ng-template> Here is the component: export class AppComponent { @ViewChild("tmpl", { read: TemplateRef, static: false }) tmpl: TemplateRef<any>; loadTemplate() { const viewRef = this.tmpl.createEmbeddedView({ $implicit: "angular" }) alert('content for static h2 element: ' + viewRef.rootNodes[0].textContent) alert('content for dynamic h2 element: ' +

Getting content of dynamic templates in component

你。 提交于 2021-02-11 05:09:57
问题 Here is the template: <button (click)="loadTemplate()">Load Template</button> <ng-template #tmpl let-name> <h2>hello</h2> <h2>{{name}}</h2> </ng-template> Here is the component: export class AppComponent { @ViewChild("tmpl", { read: TemplateRef, static: false }) tmpl: TemplateRef<any>; loadTemplate() { const viewRef = this.tmpl.createEmbeddedView({ $implicit: "angular" }) alert('content for static h2 element: ' + viewRef.rootNodes[0].textContent) alert('content for dynamic h2 element: ' +

ng serve won't compile

本秂侑毒 提交于 2021-02-11 05:02:37
问题 I'm trying to get my very first angular app compiled, but ng serve spits this error: ERROR in ./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/ang ular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embe dded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.scss) Module build failed (from ./node_modules/postcss-loader/src/index.js): Error: Failed to find 'angular/material/prebuilt-themes/deeppurple-amber.css' in [ C:\Users\juio

ng serve won't compile

房东的猫 提交于 2021-02-11 04:58:10
问题 I'm trying to get my very first angular app compiled, but ng serve spits this error: ERROR in ./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/ang ular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embe dded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.scss) Module build failed (from ./node_modules/postcss-loader/src/index.js): Error: Failed to find 'angular/material/prebuilt-themes/deeppurple-amber.css' in [ C:\Users\juio

ng serve won't compile

心不动则不痛 提交于 2021-02-11 04:57:17
问题 I'm trying to get my very first angular app compiled, but ng serve spits this error: ERROR in ./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/ang ular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embe dded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.scss) Module build failed (from ./node_modules/postcss-loader/src/index.js): Error: Failed to find 'angular/material/prebuilt-themes/deeppurple-amber.css' in [ C:\Users\juio

How to access the object in the observable list

懵懂的女人 提交于 2021-02-11 04:53:48
问题 I'm building a quiz app. My idea is to show 1 question per page. How do I subscribe and get an object inside a list using Observable. Instead of using *ngFor which display all of my objects. Is there a way to access the object one by one inside the subscribe block. export class ExerciseFlashcardPage { questions: Observable < any > ; type: string; constructor( public navCtrl: NavController, public navParams: NavParams, public afd: AngularFireDatabase ) { this.type = this.navParams.get('data');

Async pipe with rxjs

走远了吗. 提交于 2021-02-11 01:11:50
问题 I have a little problem in async pipe Here is my case , I need to run nested observables in async pipe in html because i use on push strategy and i dont want to use some workarounds or change detector reference . My problem is , when i run the code below only the first observable is called Should i add return statements? Or whats the problem ? Ts code this.http.getUsers(criteria) .pipe(map(data=>{ data.users.map(user=>{ this.http.getUserData(user.id) .pipe(map(res=>{user.data=res.data}))}}

Nested Observable/Promise (trying to block/wait flow in mapper function)

喜欢而已 提交于 2021-02-10 22:42:33
问题 I have the following code in an Angular app: services$ .pipe( map(serviceModels => { serviceModels .forEach((srv, srvIdx) => { // Resolve images in services srv.images.forEach(async (img, imgIdx) => { serviceModels[srvIdx].images[imgIdx] = await this.imageSrv.resolveImage(img).toPromise(); }); }); return serviceModels; }); [...] Result is a single emition with one value change afterwards. emit -> service.image[0] // 'unrendered-url' -> (wait) -> service.image[0] // correct-url/image-path I'm