angular6

Angular 6 : Use of access modifier while injection any service

柔情痞子 提交于 2019-12-07 10:04:01
问题 While going through the tutorial, i am coming across a strange scenario. while injecting the service in your component if you miss the access modifier it will give you error as given below, but adding it as private or public will run fine. Dont we have any default scope in Angular if we miss the access modifier ? export class UserDetailsComponent implements OnInit { name=""; lastName=""; constructor(userService : UserServiceService) { } ngOnInit() { } save(){ this.userService.saveUser(); } }

Angular 6: How to install a previous version of Angular project

左心房为你撑大大i 提交于 2019-12-07 08:56:55
问题 How I can install a previous version of Angular project with the current Angular-cli version (Angular 6). I found a command but is deprecated: ng new my_project --ng4 回答1: Since you want to use angular-cli to create new project, you need to install the version of @angular/cli that scaffolds angular 4 project. Version of @angular/cli which scaffolds the Angular 4 project is 1.4.9 . So, using npm, do npm install @angular/cli@1.4.9 , then use angular-cli commands. 回答2: You can just have package

Bootstrap 4.1.1 Navbar not working with Angular 6

試著忘記壹切 提交于 2019-12-07 05:53:55
问题 I have been trying to work on Navbar with collapse menu and dropdown link using Bootstrap 4.1.1 and Angular 6 but somehow Navbar is not working at all. I can see elements correctly but they don't function as intended. I installed Bootstrap via Angular CLI using 'ng install bootstrap --save' and Bootstrap dependencies: 'ng install jquery --save' and 'ng install popper.js --save' I also included Bootstrap, jquery and popper.js in package.json and angular.json package.json: "dependencies": { "

Angular 6 “Workspace needs to be loaded before it is used.” when trying to generate a new Component

淺唱寂寞╮ 提交于 2019-12-07 05:30:49
问题 when I create asp.net core project with angular dotnet new command does not add an angular.json file (angular 6) to the project and therefor we are not able to use angular cli. If i add angular.json file manually the project give the exception below!? Workspace needs to be loaded before it is used. Error: Workspace needs to be loaded before it is used. at Workspace._assertLoaded (D:\NetAngular\node_modules\@angular-devkit\core\src\workspace\workspace.js:59:19) at Workspace.getProjectByPath (D

Mat select options showing behind the Dialog

只谈情不闲聊 提交于 2019-12-07 04:43:30
问题 I am including form inputs, mat select with options and autocomplete field with options too into a matDialog box. The problem is that the options are showing behind the Dialog. I’ve already came across those solutions solution1 but did'nt solve this problem. here is my code: <mat-form-field class="wrapField"> <mat-select (selectionChange)="selectChange($event)" formControlName="product" placeholder="Alle Produkte"> <mat-option *ngFor="let product of products" value="{{product.id}}">{{product

TypeError: rxjs__WEBPACK_IMPORTED_MODULE_2__.Observable.throw is not a function

给你一囗甜甜゛ 提交于 2019-12-06 22:27:35
问题 Here is my file userdata.service.ts : import { Injectable } from '@angular/core'; import { Http, Response } from '@angular/http'; import {Observable} from 'rxjs'; import { map } from "rxjs/operators"; import { catchError } from 'rxjs/operators'; import { Data } from './userdata'; @Injectable() export class UserDataService { url : "http://localhost:4200/assets/data/userdata.json"; constructor(private http:Http) { } getDataWithObservable() : Observable<any>{ return this.http.get(this.url) .pipe

Ionic 4 + Angular 6 PWA Styles not working / broken

試著忘記壹切 提交于 2019-12-06 16:55:50
Hope someone can help me here, I have an Ionic 4 app using Angular 6 pwa. I have followed the steps in this post to get it working https://www.joshmorony.com/create-a-pwa-with-angular-service-workers-in-ionic-4/ All the steps complete fine and also the package builds and runs correctly without errors. However all my control specific styles are missing e.g my-controll.component.scss app-my-contol { ion-content { background-color: var(--light-gray-lightest); } .my-class { padding:0; list-style: none; position: absolute; width: 100%; left: 0; } } You can see that the files are hashed correctly

Angular 6 Role based Authentication

╄→尐↘猪︶ㄣ 提交于 2019-12-06 14:57:55
问题 I have 5 modules in my project. roll access to these modules in create, update, delete and view access based on rolls. How I create UI in angular 6 and I need the role when user login to the app and setting the role in shared service. for example admin roll access all the services and employee role only view the list not access to create and delete. I'm new to entering in angular. Please help me any codes or examples in Roll based authentication 回答1: You can create different component and

Cannot resolve tsconfig paths

妖精的绣舞 提交于 2019-12-06 14:54:09
My Angular 6 project with TypeScript version "2.7.2" has tsconfig.json as { "compileOnSave": false, "compilerOptions": { "baseUrl": "./src", "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2017", "dom" ] }, "paths":{ "@services/*": ["app/services/*"] } } I tried importing a service using the above path import { AppService } from '@services/app.service'; But I'm getting this error on running ng serve ERROR in src/app

After update to Angular 6 [WDS] Disconnected on IE after load

半腔热情 提交于 2019-12-06 14:50:37
I updated my Angular Project from 5 to 6. But now I have issues with the Internet Explorer 11. Every time I try to load the live dev server on localhost:4200 the login page renders but immediatly disconnects from the live dev server. All other Browsers work fine, no errors on the console (tried with Edge, Firefox and Chrome) My pollyfills look like this: /** * This file includes polyfills needed by Angular and is loaded before the app. * You can add your own extra polyfills to this file. * * This file is divided into 2 sections: * 1. Browser polyfills. These are applied before loading ZoneJS