angular2-cli

angular2-cli gives @multi styles error

眉间皱痕 提交于 2019-12-04 00:01:45
I started using angular2-cli recently and created a new project. I wanted to use bootstrap in my project hence I installed bootstrap and then wanted to import the bootstrap css file like it is shown in the the angular2-cli guide here. https://github.com/angular/angular-cli#global-library-installation After running ng serve I get the following error. ERROR in multi styles Module not found: Error: Can't resolve '/home/krishna/angular2_migrate/webui/node_modules/bootstrap/dist/css/bootstrap.min.css' in '/home/krishna/angular2_migrate/webui/node_modules/angular-cli/models' @ multi styles What am I

Invalid configuration object. Webpack has been initialised using a configuration

纵饮孤独 提交于 2019-12-03 17:55:51
问题 As of this morning, with Angular CLI 1.0.0-beta.14 I ng new try3 and ng serve and get the following error: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration has an unknown property 'tslint'. These properties are valid: object { amd?, bail?, cache?, context?, devServer?, devtool?, entry, externals?, loader?, module?, name?, dependencies?, node?, output?, plugins?, profile?, recordsInputPath?,

angular-cli for angular2 how to load environment variables

给你一囗甜甜゛ 提交于 2019-12-03 05:49:22
问题 I am new to the angular-cli and want to load url's for my api service calls by env. E.g. local: http://127.0.0.1:5000 dev: http://123.123.123.123:80 prod: https://123.123.123.123:443 e.g. in environment.prod.ts I assume this: export const environment = { production: true "API_URL": "prod: https://123.123.123.123:443" }; But from angular2, how do I call so I can get API_URL? e.g. this.http.post(API_URL + '/auth', body, { headers: contentHeaders }) .subscribe( response => { console.log(response

Different proxy config based on environment in Angular 2 CLI

不羁岁月 提交于 2019-11-30 20:25:29
How can I declare 2 different proxy URLs for development and production environments in Angular 2 CLI project? For example, while in development mode, I would like to use { "/api/*": { "target": "http://localhost:3000", "secure": false } } but in production mode, I will use { "/api/*": { "target": "http://api.exampledomain.com", "secure": false } } I do not believe you can control the proxy feature through the environment files. An alternative could be to define your api domains in your environment files // environment.ts export const environment = { production: false, api: 'http://localhost

How to serve an angular2 app in a node.js server

£可爱£侵袭症+ 提交于 2019-11-30 13:41:34
I'm building a web app using Angular2, to create the project I'm using Angular2 CLI webpack. Angular2 app uses other external packages also (Eg: Firebase). In addition to that, I need to create a REST API running on node.js How can I serve both of Angular2 app and REST API using node.js server John Siu Use ng build to build your app into build directory. Create nodejs app to server the build directory as static content, then create route for api. Following is an example of nodejs app using express that will serve the Angular2 app: /* Put content of angular2 build into 'public' folder. */ const

angular2-cli include custom fonts

﹥>﹥吖頭↗ 提交于 2019-11-30 12:43:02
问题 I am trying to include some custom fonts in my project with no success. NOTE: I am using angular-cli: angular-cli@1.0.0-beta.21 I put the fonts in folder src/assets/fonts/Roboto-Regular.tff I add in src/styles.css @font-face { font-family: "Roboto-Regular"; src: url("./assets/fonts/Roboto-Regular.tff"); } I use it in a component .scss font-family: "Roboto-Regular"; I get 404 error: Cannot find module "./assets/fonts/Roboto-Regular.tff" client?93b6:80 ./~/css-loader?sourcemap!./~/postcss

Different proxy config based on environment in Angular 2 CLI

允我心安 提交于 2019-11-30 04:03:19
问题 How can I declare 2 different proxy URLs for development and production environments in Angular 2 CLI project? For example, while in development mode, I would like to use { "/api/*": { "target": "http://localhost:3000", "secure": false } } but in production mode, I will use { "/api/*": { "target": "http://api.exampledomain.com", "secure": false } } 回答1: I do not believe you can control the proxy feature through the environment files. An alternative could be to define your api domains in your

angular2-cli include custom fonts

不问归期 提交于 2019-11-30 02:56:36
I am trying to include some custom fonts in my project with no success. NOTE: I am using angular-cli: angular-cli@1.0.0-beta.21 I put the fonts in folder src/assets/fonts/Roboto-Regular.tff I add in src/styles.css @font-face { font-family: "Roboto-Regular"; src: url("./assets/fonts/Roboto-Regular.tff"); } I use it in a component .scss font-family: "Roboto-Regular"; I get 404 error: Cannot find module "./assets/fonts/Roboto-Regular.tff" client?93b6:80 ./~/css-loader?sourcemap!./~/postcss-loader!./src/styles.css Module not found: Error: Can't resolve './assets/fonts/Roboto-Regular.tff' in 'D:

Angular 6 + CLI (TypeScript) - How to stop generating .spec.ts test files

夙愿已清 提交于 2019-11-30 02:54:00
I KNOW IT'S KIND OF A BAD PRACTICE, but pair with me: I'm using Angular-CLI and particularly ng g to generate all of my classes, however, I'm not interested in any test file *.spec.ts and I know that there are two flags ( --inline-template , --inline-style ) to handle inline CSS and HTML instead of separated files. and for spec the default flag is set to true --spec So for each run, yes, I can do so ng g c foo --it --is --spec=false But How to disable the creation of test files globally? is there any default setting for it? Rashly, I did some stuff like (that didn't work) : ng set spec=false -

How to use jsPDF with angular 2

冷暖自知 提交于 2019-11-27 17:28:08
I got an Error: jsPDF is not defined , I am currenty using following code : import { Component, OnInit, Inject } from '@angular/core'; import 'jspdf'; declare let jsPDF; @Component({ .... providers: [ { provide: 'Window', useValue: window } ] }) export class GenratePdfComponent implements OnInit { constructor( @Inject('Window') private window: Window, ) { } download() { var doc = jsPDF(); doc.text(20, 20, 'Hello world!'); doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.'); doc.save('Test.pdf'); } } I have install npm of jsPDF but don't know how import jspdf and run with