angular5

Pass Razor model to Angular 5 component

冷暖自知 提交于 2019-12-11 09:09:42
问题 I have this in my asp.net razor view: @model IEnumerable<MyClass> <app-root [(myModel)]="'@Model'"></app-root> and this import { Component } from '@angular/core'; import { Input } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styles: [] }) export class AppComponent { title = 'app'; @Input() public myModel: any; ngOnInit() { console.log(this.myModel); } } Output in console says "udefined"... I have tried to name 'myModel' as ngModel, i have tried

Rerouting angular 5 app with AngularFireAuth

有些话、适合烂在心里 提交于 2019-12-11 08:37:19
问题 I got the simple authentication working with AngularFireAuth but now my routing doesn't work anymore the console.logs show that the 'test' comes before the 'Nice it worked', so what is wrong? (this is mainly just the routing guard out of the documentation) auth-service @Injectable() export class AuthService { user: Observable<firebase.User>; constructor(private firebaseAuth: AngularFireAuth){ this.user = firebaseAuth.authState; } isLoggedIn = false; login(email: string, password: string):

angular 5, RxJs { map } import doesn't work or i'm missing something?

纵然是瞬间 提交于 2019-12-11 07:41:12
问题 I'm trying to map the result of my httpclient and we need to use the new import for RxJs to get the treeshaking working. so i've found 2 map but none work... import { map } from 'rxjs/operator/map'; import { map } from 'rxjs/operators/map'; the old fashion way that we need to remove import 'rxjs/add/operator/map'; Here is the code i need to get to work! getValues(): Observable<Value[]> { return this.http.get<Response<Values>>(this.url).map(reponse => { return reponse.data.values; }); } but

Angular 5 StaticInjectorError:[Http]

假装没事ソ 提交于 2019-12-11 06:56:42
问题 hello i am getting such an error what is the reason for this? StaticInjectorError[Http]: StaticInjectorError[Http]: NullInjectorError: No provider for Http! at NullInjector.get (core.js:923) at resolveToken (core.js:1211) at tryResolveToken (core.js:1153)enter code here at StaticInjector.get (core.js:1024) at resolveToken (core.js:1211) at tryResolveToken (core.js:1153) at StaticInjector.get (core.js:1024) at resolveNgModuleDep (core.js:10585) at NgModuleRef.get (core.js:11806) at resolveDep

How to read and write local file using angular 2

假装没事ソ 提交于 2019-12-11 06:45:19
问题 In angular 2, is there any way to read/write files from absolute path? I have used ' filesaver ' library to save the file, where I save the file locally in txt/json format. Example : let blob = new Blob([document.getElementById('exportFile').innerHTML],{ type: "text/plain;charset=utf-8" }); saveAs(blob, "export.json"); Now I want to read and write/edit export.json file. How can I refer it for the next time? Is there any other way or is there any good library available for these operations?

Angular 5 sort by date

不问归期 提交于 2019-12-11 06:41:44
问题 I have a table of lessons and I would like to order them by date. Since Angular 5 doesn't have the orderBy pipe and all the solutions I have found so far can only be applied to numbers and strings I would be grateful if someone could help me with this. This is the body of my table <tbody> <tr *ngFor="let lesson of lessons"> <th scope="row">{{lesson.date | date:'dd.MM.yyyy H:mm'}}</th> <td>{{lesson.address.locationName}}</td> <td>{{lesson.topic}}</td> <td>{{lesson.homework}}</td> </tr> </tbody

ng serve command not working angular 5

百般思念 提交于 2019-12-11 06:34:39
问题 If I run ng serve, getting this error ng : The term 'ng' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + ng serve + ~~ + CategoryInfo : ObjectNotFound: (ng:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException I have tried npm run ng serve, getting this error Local workspace file ('angular.json')

Angular 5 Form validation, not accessing validators properties

元气小坏坏 提交于 2019-12-11 06:34:30
问题 I have created a registration form and trying to validate it using Angular 5 form's validators. I have gone through other threads on StackOverflow also tried the solution explained in - Angular 5 ngx-bootstrap form validation but i am unable to solve my issue. My html is - <div class="was-validated"> <form [formGroup]="myform" novalidate role="form"> <div class="row main"> <div class="main-login main-center" style="padding-top:0px;"> <form class="form-horizontal" method="post" action="#">

Angular5 Universal lazy loading on firebase hosting and seo

倾然丶 夕夏残阳落幕 提交于 2019-12-11 06:04:28
问题 Does anyone know howto get lazyloading on firebase hosting working? It all works but when I view the source code of my site, I only see the router-outlet and not the text and so on. I've added the code below to my index.js inside the functions folder: extraProviders: [ provideModuleMap(LAZY_MODULE_MAP) ] My app.server.module file looks like this: import { NgModule } from '@angular/core'; import { ServerModule } from '@angular/platform-server'; import { AppModule } from './app.module'; import

Problem with image printing using ngx-print

倖福魔咒の 提交于 2019-12-11 05:48:22
问题 Image is not getting printed with ngx-print. I am not sure what am I doing wrong here. HTML <button type="button" printTitle="PrintVoucher" [useExistingCss]="true" printSectionId="printVoucher" ngxPrint> Print </button> <div row id="printVoucher" > <img src="assets/images/logo.png"> </div> However the image is visible on the screen , but not visible in the print preview section. 回答1: you have to use absolute path , Not relative path ie your path should be for example "http://localhost:3000