angular-providers

Angular Async Factory Provider

∥☆過路亽.° 提交于 2019-12-09 15:39:55
问题 I would like to set up a factory that does async work to return a service, and then provide that factory to a factory provider to provide that service to a component when it loads. However, when the provider injects the TestService into the TestComponent , the type at runtime is ZoneAwarePromise . I need a way to have the provider automatically "await" the promise before it injects the service into the component. Service export class TestService { public test() { return 123; } } Provider and

Angular Async Factory Provider

让人想犯罪 __ 提交于 2019-12-04 03:48:22
I would like to set up a factory that does async work to return a service, and then provide that factory to a factory provider to provide that service to a component when it loads. However, when the provider injects the TestService into the TestComponent , the type at runtime is ZoneAwarePromise . I need a way to have the provider automatically "await" the promise before it injects the service into the component. Service export class TestService { public test() { return 123; } } Provider and Factory export function testFactory(auth: any, temp: any) { return new Promise((res, rej) => { res(new

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

痞子三分冷 提交于 2019-11-29 12:55:34
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? In this application you can route between sub modules easily: Create main application " mainApp.js " angular.module("mainApp", [ "ui.router" ]); angular.module("mainApp").config([ "$stateProvider", "$urlRouterProvider", function(

Possibly unhandled rejection in Angular 1.6

半世苍凉 提交于 2019-11-29 02:52:33
I have a code with AngularJS: service.doSomething() .then(function(result) { //do something with the result }); In AngularJS 1.5.9 when I have error in the .then() section like: service.doSomething() .then(function(result) { var x = null; var y = x.y; //do something with the result }); I'm getting clear error message: TypeError: Cannot read property 'y' of null But in version 1.6 with the same code I'm getting a different error: Possibly unhandled rejection: {} undefined I know that this is related to this change , and the single solution is quite simple by adding .catch() block: service

Possibly unhandled rejection in Angular 1.6

佐手、 提交于 2019-11-27 17:10:37
问题 I have a code with AngularJS: service.doSomething() .then(function(result) { //do something with the result }); In AngularJS 1.5.9 when I have error in the .then() section like: service.doSomething() .then(function(result) { var x = null; var y = x.y; //do something with the result }); I'm getting clear error message: TypeError: Cannot read property 'y' of null But in version 1.6 with the same code I'm getting a different error: Possibly unhandled rejection: {} undefined I know that this is