angular-providers

Angular: Metadata collected contains an error that will be reported at runtime: Lambda not supported

牧云@^-^@ 提交于 2020-06-27 14:50:08
问题 In my Angular app, I'm trying to use a factory provider in my module: export function getMyFactory(): () => Window { return () => window; } @NgModule({ providers: [ { provide: WindowRef, useFactory: getMyFactory() }, ], }) export class MyModule {} but this is failing with: Error encountered in metadata generated for exported symbol 'MyModule': Metadata collected contains an error that will be reported at runtime: Lambda not supported 回答1: I've found an easy solution reported on a thread from

Nativescript/Angular extending HttpClient

为君一笑 提交于 2020-01-16 09:41:50
问题 I'm since I'm adding nativescript-https to my Nativescript/Angular app I'm making a wrapper. So, since Nativescript's NativeScriptHttpClientModule uses Angular's HttpClientModule I'm extending HttpClient, and I created the http-client.ts file: import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable, from } from 'rxjs'; import * as Https from 'nativescript-https' export interface IRequestOptions { headers?:

Nativescript/Angular extending HttpClient

天大地大妈咪最大 提交于 2020-01-16 09:41:32
问题 I'm since I'm adding nativescript-https to my Nativescript/Angular app I'm making a wrapper. So, since Nativescript's NativeScriptHttpClientModule uses Angular's HttpClientModule I'm extending HttpClient, and I created the http-client.ts file: import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable, from } from 'rxjs'; import * as Https from 'nativescript-https' export interface IRequestOptions { headers?:

The semantics of @Injectable(providedIn: 'root')?

我怕爱的太早我们不能终老 提交于 2020-01-14 12:17:06
问题 Just want to make sure I understand the semantics of @Injectable(providedIn: 'root') . Prior to Angular 6 if we import a module from NPM that contains a service we would declare that module in our app module such that the entire application has access to the service. Something like this: import { SomeNPModule } from '@ngx/SomeNPModule'; @NgModule({ imports: [ BrowserModule, SomeNPModule ] }) export class AppModule {} Now we can inject the SomeService that the module provides because we have

Creating nested route app in angular using angular-ui-router and switching between modules

☆樱花仙子☆ 提交于 2020-01-10 04:46:24
问题 I want to create angular nested routes in my application using angular-ui-router with multi sub-modules; In " ui-router " we can use multi views in our main app config as $stateProvider , but can't switch between sub-modules when you are in other module. For example when you are in " module1 " you can not state to " module2 ". So, How can I switch between my modules? 回答1: In this application you can route between sub modules easily: Create main application " mainApp.js " angular.module(

Angular: load environment properties before config/run

六月ゝ 毕业季﹏ 提交于 2020-01-07 02:49:35
问题 I'm developing a angular app, and this app has about a 10 configurable properties (depending on the environment and client). I had those properties in json config files, but this is really troublesome: there must be specific builds per env/company. So I would like to retrieve those properties once from the backend on app load. So in order to do this I created a Provider var app = angular.module('myApp', [...]); app.provider('environment', function() { var self = this; self.environment; self

Angular: load environment properties before config/run

可紊 提交于 2020-01-07 02:49:04
问题 I'm developing a angular app, and this app has about a 10 configurable properties (depending on the environment and client). I had those properties in json config files, but this is really troublesome: there must be specific builds per env/company. So I would like to retrieve those properties once from the backend on app load. So in order to do this I created a Provider var app = angular.module('myApp', [...]); app.provider('environment', function() { var self = this; self.environment; self

Angular UrlResolver is not overridden by custom provider

混江龙づ霸主 提交于 2019-12-24 09:40:04
问题 I have an Angular application in which I'd like to use a custom UrlResolver provider in order to add some cache breaking logic, as seen in this question (https://stackoverflow.com/a/43289767/868914). However it doesn't seem that I can override the default compiler UrlResolver using a provider, as I would normally do and as the above link suggests. Here is a plunker showing what I mean: https://plnkr.co/edit/zFsdyfNIoPcmbLO7WafW?p=preview If you use the chrome (or other good) dev tools

Angular2 what is providers, when injector create service instance with provider, [duplicate]

独自空忆成欢 提交于 2019-12-13 09:52:04
问题 This question already has answers here : What are providers in Angular2? (5 answers) Closed 2 years ago . I really want to know What is providers? what relationship with DI in angular2? app.module.ts @NgModule({ imports: [ BrowserModule, FormsModule, ], declarations: [ test, ], bootstrap: [ AppComponent ], providers: [ userService ] }) export class AppModule { } test.component.ts export class TestComponent implements OnInit, OnDestroy { constructor(public user: userService) } In my

Why does this test for the angular-google-maps provider fail?

好久不见. 提交于 2019-12-12 10:34:21
问题 I'm trying to test a module that uses angular-google-maps . It is failing because angular.mock.inject cannot find uiGmapGoogleMapApiProvider : Error: [$injector:unpr] Unknown provider: uiGmapGoogleMapApiProviderProvider <- uiGmapGoogleMapApiProvider I can't figure out what is going wrong. Here is the reduced testcase: 'use strict'; describe('this spec', function() { beforeEach(module('uiGmapgoogle-maps')); it('tries to configure uiGmapGoogleMapApiProvider', inject(function