腾讯云
开发者社区
文档
建议反馈
控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
登录/注册
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
视频
沙龙
2
回答
在Angular中的promise块之外使用变量
angular
、
typescript
、
promise
、
angular6
如何在Angular 6中的组件中的promise块之外获取变量? 例如 items:string[]=[]; ngOnInit{ const url='SOME URL'; const promise = this.apiService.post(url); //Response promise.then(response => { this.items.push('abc'); this.items.push('def');
浏览 32
提问于2019-09-03
得票数 0
3
回答
当异步函数等待表达式“暂停”执行时,“暂停”是什么意思?
javascript
、
angular
、
asynchronous
、
promise
我对Javascript中的异步概念非常陌生,我想确保我没有误解我正在阅读的内容。 考虑一下某些Angular应用程序中的伪代码: async ngOnInit() { this.responseObject = await this.myService.myGetRequest(); //do some more stuff down here } 我的理解是,ngOnInit()会在等待时‘暂停’或停止执行,并且在返回promise对象(数据)之前不会执行该行下面的代码?对,是这样?
浏览 1
提问于2017-11-03
得票数 1
2
回答
为什么我的异步角茉莉花单元测试不能工作?
angular
、
unit-testing
、
jasmine
我正在尝试测试一个异步组件方法,我认为我正确地使用了角4的异步测试功能,但是它不起作用。我的问题是,当我运行测试时,不会等待来解决这个问题。函数的异步特性似乎导致超时被触发,测试过早退出。测试无论如何都会通过,因为expect()中的所有whenStable()语句都会被跳过。 如果我省略了async()包装函数,切换到传入done回调并在whenStable()块末尾调用它的Jasmine语法,它将正确工作。有人能告诉我为什么它不能与角async()包装一起工作吗? 我的代码如下所示: // my.component.ts ngOnInit() { this.getResults().t
浏览 2
提问于2017-06-16
得票数 3
回答已采纳
1
回答
为什么angular2对象不能在ngOnInit中访问?
typescript
、
angular
、
angular2-services
我现在正在研究angular2很长一段时间,我想知道为什么我不能访问ngOnInit()中的对象,但它们在服务调用中是可以访问的。为了前夫。 import { Component} from 'angular2/core'; import { GlobalService} from './../../app/shared/services/global/global.service'; import { GlobalObjectsService} from './../../app/shared/services/global/global.object
浏览 0
提问于2016-05-18
得票数 1
回答已采纳
2
回答
Angular4 -为什么承诺从服务解析到未定义?
angular
、
typescript
、
promise
、
angular-services
、
arrow-functions
我在努力从一个承诺中得到一个未知的回报。从我的检测工作来看,问题似乎是将承诺的结果分配给组件上的一个实例变量,而我就是在这个组件上调用诺言的。我认为这是箭头函数的一个类型(或类似的)问题,我试图将返回的调查分配给this.survey。 任何洞察力都将不胜感激! ./survey.service.ts import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { SURVEYS } from './mock-survey
浏览 1
提问于2017-07-28
得票数 0
1
回答
用茉莉花进行Angular2异步单元测试
unit-testing
、
angular
、
asynchronous
、
jasmine
我正在编写一个angular2应用程序,并且很难理解如何使用茉莉编写异步代码测试。不管出于什么原因,我没有看到太多的例子,似乎非常适用于我的情况。 我目前正在尝试测试一个对另一个服务具有异步依赖关系的服务(而不是组件)。我不能100%确定在测试的哪一点检查异步调用的结果是有效的。您可以在异步处理程序中调用服务的expect()吗? service.foo() .then((data) => { //do I check the results in here? expect(data).toEqual({ a: 1, b: 2 });
浏览 1
提问于2017-03-20
得票数 7
回答已采纳
1
回答
角质2从url得到值并承诺并等待
angular
、
typescript
因此,我正在尝试从url中获取值,并且我想要通过承诺和异步/等待来完成这一任务。但是,当我在镀铬和歌剧中运行这个程序时,它只是站在那里等待这一点。有人能把我引向正确的方向,还是我做错了什么? 我的组件实现:实现OnInit 构造者: constructor(private route: ActivatedRoute, private zone : NgZone ) { } 进口: import { Component, OnInit, NgZone } from '@angular/c
浏览 1
提问于2017-05-28
得票数 1
回答已采纳
1
回答
异常: Uncaught (承诺中):错误由:无法读取未定义的属性“名称”引起
angular
我是Angular2新手。当我尝试将这些代码添加到camp.detail.component.html中时(获得详细信息/:id视图), {{campDetail.campground.name}} 它总是显示以下错误消息: 当我移除 {{campDetail.campground.name}} 然后没有错误消息,我们可以看到这个对象被打印在控制台中: 我做了很多搜索,尝试了尽可能多的解决方案,但仍然找不到合适的方法来解决这个问题。(例如:,,, ) 如何解决此异常?任何建议都会对我有帮助和帮助。我真的很感激。 我的档案如下: campgrounds.servic
浏览 1
提问于2017-02-08
得票数 0
3
回答
在Angular 2 ngOnInit中测试promise
jasmine
、
angular
我有一个Angular 2组件,我正试图对其进行测试,但我遇到了问题,因为数据是在ngOnInit函数中设置的,所以在单元测试中不能立即使用。 user-view.component.ts: import {Component, OnInit} from 'angular2/core'; import {RouteParams} from 'angular2/router'; import {User} from './user'; import {UserService} from './user.service'; @Co
浏览 1
提问于2016-02-15
得票数 20
回答已采纳
1
回答
异步Validator,其中api在false情况下返回404。Angular4
angular
import { Component, OnInit } from '@angular/core'; import { FormGroup, FormControl, Validators, FormArray } from '@angular/forms'; import { AService } from "app/a/services/a.service"; import { Subscription } from 'rxjs/Subscription'; import { Observable } from "rx
浏览 0
提问于2017-07-28
得票数 0
回答已采纳
1
回答
角2属性在ngOnInit上未定义
angular
、
typescript
我刚开始使用AngularJs 2开发网页,我也没有使用AngularJs 1的经验。所以,如果我问了些蠢事,我很抱歉。我被困在一个问题上,我搜索了它,但我找不到任何解决办法。:/ 问题是: 我试图在一个名为末尾的函数中使用ngOnInit,这个属性是我在ngOnInit上初始化的一个对象的属性,但是这个对象仍然是未定义的,所以我得到了以下异常: Error: Uncaught (in p**strong text**romise): TypeError: Cannot read property 'secretariatId' of undefined 这是我的组成部分: i
浏览 3
提问于2016-10-18
得票数 1
回答已采纳
1
回答
如何在数据服务提供的模板中使用css属性?
json
、
angular
、
observable
、
sanitization
、
dataservice
我需要生成经过净化的css属性,以便与组件模板一起使用,以设置div的背景图像: <div *ngFor="let Item of Items" [style.background-image]="Item.imageStyle (click)="gotoDetail(Item.iditems)"> </div> 使用通过数据服务获得的数据。构成部分是: import { Component } from '@angular/core'; import { Router } from
浏览 3
提问于2016-10-26
得票数 0
回答已采纳
1
回答
Range6-生命周期钩子中的承诺使其他测试失败。
angular
、
typescript
、
testing
、
jasmine
、
karma-jasmine
我的角度测试有问题。我不知道这是个错误,还是我做错了什么。 我有两个部件。一个使用ngOnInit中的承诺,另一个则完全是空的。 使用允诺的组件如下所示: import {Component, OnInit} from '@angular/core'; import {User, UserManager} from 'oidc-client'; @Component({ selector: 'app-test', templateUrl: './test-promise.component.html', styleU
浏览 1
提问于2018-09-24
得票数 1
回答已采纳
2
回答
Angular2:从服务器加载异步数据
angular
我想在我的角度应用程序中从服务器加载数据。但是数据请求是async,我无法正确地获取数据。首先,我传递url参数。基于参数,我从ngOnInit()加载数据,但是数据加载不正确。我搜索了几个小时,但没有解决办法。我的代码如下: 服务 import { Injectable } from '@angular/core'; import { Headers, Http } from '@angular/http'; import 'rxjs/add/operator/toPromise'; import {Author} from './au
浏览 0
提问于2017-03-18
得票数 0
回答已采纳
3
回答
Angular2:如何在呈现组件之前加载数据?
typescript
、
angular
、
angular2-services
、
angular2-http
在呈现组件之前,我正在尝试从API加载一个事件。目前,我正在使用我的API服务,我从组件的ngOnInit函数调用该服务。 我的EventRegister组件: import {Component, OnInit, ElementRef} from "angular2/core"; import {ApiService} from "../../services/api.service"; import {EventModel} from '../../models/EventModel'; import {Router, ROUTER_DIRE
浏览 4
提问于2016-02-26
得票数 173
回答已采纳
3
回答
如何在promise中更新全局变量并返回到其他组件中使用
angular
、
typescript
、
global-variables
、
es6-promise
、
angular-promise
问题是我有一个想要显示的用户名,但无法从promise之外获取数据。 我制作了一个user.service.ts,并将其作为提供者包含在app.module.ts中。然后在app.component.ts中,我将user设置为等于返回的数据,但它不起作用。为什么不能像这样在promise中更新全局变量呢? user.service.ts import { Injectable } from '@angular/core'; import { AuthGuardService } from './auth-guard.service'; @Injectable(
浏览 0
提问于2018-12-20
得票数 0
2
回答
OnInit中的Angular2无法访问来自服务的数据
angular
、
typescript
、
lifecycle
我创建了一个WorkingData对象,用于在组件之间传递某些数据。对象的一个成员是today,它是包含当前日期的Date对象。我希望在setInterval函数中每秒钟更新一次,但此时workingData对象未定义,给出了控制台错误: Cannot set property 'today' of undefined app.component.ts import { Component, OnInit, AfterContentChecked } from '@angular/core'; import { WorkingData } from '.
浏览 5
提问于2016-11-14
得票数 0
回答已采纳
1
回答
为什么测试断言进入订阅而不在异步区域中?
angular
、
unit-testing
、
rxjs
、
karma-runner
当使用Karma和Jasmine在Angular2+中运行测试,并订阅可观察对象时,订阅(据我所知)是异步运行的,因此测试应该包装到async或fakeAsync中。 但是我们不使用async,不使用fakeAsync,测试通过了,所以我的问题是:subscribe中的代码过去不是异步的吗?为什么测试通过了?怎么一回事? hello.component.ts import { Component, Input, OnInit } from '@angular/core'; import {of} from 'rxjs'; @Component({ sel
浏览 21
提问于2019-02-20
得票数 0
回答已采纳
1
回答
为什么这个变量总是返回null?角服务
javascript
、
angular
、
httpclient
、
angular-services
现在花了8个小时来解决一个琐碎的问题&我真不敢相信! 下面是一个角服务脚本 import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; @Injectable({ providedIn: 'root' }) export class GetStockDataService { constructor(public http:HttpClient) { } RequestData={"
浏览 5
提问于2020-01-20
得票数 0
3
回答
我如何访问这个变量?this.hero
angular
、
typescript
、
web
于是我浏览了went网站上的文档,并构建了基本的“英雄”应用程序。 我一直试图访问输入变量英雄,因为我有一个特定的变量,我想输出,但我得到了错误。 Error: Uncaught (in promise): TypeError: this.hero is undefined 这个调用在任何其他方法中都有效,例如在按钮使用期间调用的方法,但是一旦我试图在ngOnInit()中调用它,它就会崩溃并给出错误。 这是我的密码: this.route.params.switchMap((params: Params) => this.heroService.getHero(+params['
浏览 2
提问于2017-05-15
得票数 0
回答已采纳
1
回答
AsynPipe和this._strategy的无效管道参数'‘为空
angular
因此,我创建了一个项目模块(包括服务、组件等)。 但是我得到了一个Invalid pipe argument '' for AsynPipe错误 作为数据示例,我使用了一个写得很好的json文件(似乎没有错误)。 您可以在github:上找到我的项目 这段代码对我来说似乎很好,并找到了一些类似的例子。我不知道消息的意思是什么,因为它在单引号之间是空的。 我对(articles | async)进行了分组,因为我预期我可能会稍后在ngFor中计算项目。 如果我使用了And (),我就得到了一个this._strategy is null。我也找不到任何信息。 下面是有关的代码(如
浏览 3
提问于2017-08-30
得票数 0
1
回答
如何在控制台日志之外获取IPC消息的值?
javascript
、
angular
、
typescript
、
electron
、
ipc
我正在使用电子和角度开发一个应用程序,我试图发送一些存储在我的计算机本地的信息。我能够在正确的时间成功地将信息从电子侧发送到角侧。但是,除了控制台日志之外,我无法在其他任何地方访问该消息。 file.service.ts: import { Injectable } from '@angular/core'; import { IpcRenderer } from 'electron'; @Injectable({ providedIn: 'root' }) export class FileService { private ipc
浏览 19
提问于2021-01-05
得票数 0
回答已采纳
1
回答
因果报应等待包含要完成的承诺的无效
angular
、
karma-jasmine
在我的组件的ngOnInit()中,我调用了一个getAllUsers方法,该方法进行了UserService promise调用。我想简单地做一个测试: it('should get initialized', async(inject([MockBackend], (backend: MockBackend) => { spyOn(component, "getAllUsers") component.ngOnInit() expect(component.getAllUsers).toHaveBeenCalled()
浏览 0
提问于2017-07-21
得票数 1
回答已采纳
1
回答
从服务中从HttpClient获取JSON数据的角度不能正常工作
angular
、
typescript
、
async-await
、
angular-promise
、
angular-httpclient
我正在尝试使用服务获取JSON数据的角度,并使用HttpClient使用get()方法获取数据。问题是,我使用的是诺言,函数返回的是一个包含它的值的承诺。 我在控制台中打印了值,它正在返回: ZoneAwarePromise {__zone_symbol__state: null,__zone_symbol__value: Array(0)}控件:(22) [{…]},{…},{…},{…},{…},{…},{…},} 以下是服务代码: import { Injectable } from '@angular/core'; import { HttpClient
浏览 8
提问于2022-06-23
得票数 0
回答已采纳
2
回答
角4异步管道不工作
angular
我正在尝试使用异步管道,但是没有显示数据。我正在记录来自服务器的数据,它在控制台中显示得很好。但由于某些原因,我无法让异步运行。 shift.service.ts import { Injectable } from '@angular/core'; import { Shift } from '../shift/shift'; import { HttpClient } from '@angular/common/http'; @Injectable() export class ShiftService { constructor(p
浏览 3
提问于2017-09-26
得票数 1
回答已采纳
3
回答
角2服务函数正在返回未定义的组件。
angular
在读取时,我将从Component从Service返回数组。但是我在组件中没有定义,而不是在组件中产生数组。 服务: getItems(): Promise<any>{ var items = [{id:1}{id:2}{id:3}]; return Promise.resolve(items); } 构成部分A: ngOnInit(): void { this.service.getItems() .then(result => this.items= result);
浏览 5
提问于2017-09-08
得票数 1
回答已采纳
1
回答
控制台日志行为-无法读取对象属性
angular
、
object
、
properties
、
undefined
、
undefined-behavior
我正在构建一个angular web应用程序。 在组件的ngOnInit中: public ngOnInit() { this.log.debug("INSTANCE", this.Instance); this.log.debug("ACTIVITY",this.Instance.entity); this.log.debug("CREATED AT", this.Instance.created_at); // Other staff... } 我得到了以下结果: ? 这怎么可能呢?我无法读取
浏览 17
提问于2019-02-16
得票数 1
回答已采纳
2
回答
Angular 2同步Http服务
angular
目前,我在angular js2中遇到了关于登录认证的问题,因为我在下面的代码中遇到了关于异步的问题。 import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; import { UserData } from './UserData'; import 'rxjs/add/operator/map' import 'rxjs/add/operator/toPromise'
浏览 0
提问于2016-10-22
得票数 3
2
回答
角:无法读取属性'forEach‘的未定义-问题(即使应该定义)
javascript
、
angular
、
typescript
我试图在用户组件中访问有关用户的数据,我调用logUsers()将用户数据打印到控制台。这是我的组成部分: import { Component, OnInit } from '@angular/core'; import { GetDbDataService} from '../get-db-data.service'; import { User } from '../user'; @Component({ selector: 'app-users', templateUrl: './users.compon
浏览 2
提问于2020-02-21
得票数 0
回答已采纳
4
回答
如何以ngOnInit角度从服务中获取数据
angular
、
ionic-framework
、
service
、
async-await
我试图从http服务获取ngOnInit中的数据时遇到了问题。在触发组件时,我需要在var中设置数据,这样我就可以在其他函数中使用它。 我已经通过执行异步ngOnInit实现了这一点,并且收到了来自诺言函数的响应,但我认为这不是一个好的实践吗?我该如何改进呢? 这是我的代码: COMPONENT.TS async ngOnInit() { this.username = localStorage.getItem('username'); this.segment.value = 'FUNCIONAL';
浏览 3
提问于2019-10-16
得票数 0
回答已采纳
1
回答
Angular2 OnInit,不从服务器获取数据
angular
、
constructor
我在使用NgOnInit函数从服务器获取数据时遇到问题。有了这些数据,我想用morris.js绘制一个图,但我得不到这些数据。 我有一个从DB获得所有汽车赔偿的服务,然后我想画一个总赔偿的每日图。我得到了一个无效的赔偿数组,我不能画任何东西。 我的代码: constructor(_router: Router, public http: Http, private _reparacionsService: ReparacioService) { this.router = _router; } getReparacions() { this._reparacionsServi
浏览 2
提问于2016-07-24
得票数 0
1
回答
异步自定义验证会导致控制台出现错误:"Cannot read property 'required‘of null at Object.eval [as updateDirectives]“
angular
、
validation
、
typescript
目前,我正在编写Maximilianüller Angular 4教程的reactive-forms作业。在作业中,我必须创建一个反应式表单,我做到了。然后,我必须创建一个自定义的异步验证器,用于检查控件的值。它不应该等于'Test‘。这是我的打字代码: import {Component, OnInit} from '@angular/core'; import {FormControl, FormGroup, Validators} from '@angular/forms'; import {Observable} from 'rxjs/
浏览 2
提问于2017-08-01
得票数 15
回答已采纳
1
回答
NodeJS错误试图在mongo : UnhandledPromiseRejectionWarning中查找数据
javascript
、
node.js
、
angular
、
express
、
authentication
我正在使用平均堆栈中的登录来做一个应用程序。这个登录的特点之一是社交登录,关键是当一个新用户想要使用facebook进入应用程序时,我必须检查这个facebook是否已经记录在我的mongoDB中,或者没有记录在下面的代码中: 从前端页面: 1.-登录页 import { Component, OnInit } from '@angular/core'; import { AuthService } from "../services/auth.service"; import { Router } from "@angular/router"
浏览 5
提问于2020-06-24
得票数 0
回答已采纳
2
回答
如何在不对ngOnInit方法使用异步的情况下等待调用?
angular
我有下面的代码。要等待异步调用,我将使用以下命令 testi() { return new Promise((resolve,reject) => { resolve(true); }) } async ngOnInit() { let pp = await this.testi(); console.log('pp', pp); } 还有其他方法可以在这里等待调用而无需在我的async方法上添加ngOnInit符号吗?
浏览 9
提问于2021-12-16
得票数 -1
1
回答
有角度的,可观察的,承诺的
javascript
、
angular
、
promise
、
observable
我从angular.io那里学到了角,我认为我对观察和承诺有很好的把握(是的,我知道它们不是角特定的)。 然而,在这些例子中,我发现了一些让我困惑的东西。 所以不要复制/粘贴所有东西;我们有HeroService服务类 其中一种方法是: getHero(id: number | string) { return heroesPromise .then(heroes => heroes.find(hero => hero.id === +id)); } 没有问题,方法使用heroesPromise调用then,它返回Promise<Hero>。 因此,
浏览 4
提问于2017-04-03
得票数 0
回答已采纳
1
回答
不编译角迭代对象。
angular
、
rxjs
我正在尝试用动态搜索在Angular+RxJS中调整一个示例。 html: <header> <input type="text" [(ngModel)]="searchString" (ngModelChange)="inputChanged($event)" placeholder="Search"> <button (click)="searchString = ''">Clear</button> </header>
浏览 2
提问于2021-11-15
得票数 0
回答已采纳
1
回答
Angular Async Local Storage Promise解决空
angular
如何将Async Local Storage Observable转换为promise并正确转换? 我正在尝试使用Angular Async Local Storage项目缓存一些服务数据: 数据会正确地保存到本地IndexDb (我在Chrome Dev工具中查看过)。问题是我不能把数据拿出来。promise解析为空。这就是问题所在: 结果=> this._storage.getItem(this._objectKey).toPromise(); 下面是完整源代码的链接: 下面是带有缓存的完整服务类: // 3rd party imports import { Injectable }
浏览 1
提问于2017-05-12
得票数 0
1
回答
误差允诺未解析角2
angular
、
typescript
我从角2文档中了解到,ngOnInit方法是从服务器获取数据的地方,因此我所做的工作有问题: 组件 import { Component, OnInit } from '@angular/core'; import { Champion } from './champion' import { ChampionService } from './champion.service'; import { ActivatedRoute } from '@angular/router'; @Component({ sele
浏览 2
提问于2016-09-24
得票数 0
回答已采纳
1
回答
尝试加载模拟数据时,Angular2应用程序会崩溃
typescript
、
angular
、
promise
我正在尝试用一个允诺加载模拟的数据,就像Angular2教程“它是”一样。 服务(模拟): import { Injectable } from '@angular/core'; import { ERGEBNISSE } from "./mock-ergebnisse"; @Injectable() export class ErgebnisMockService { getErgebnisse() { return Promise.resolve(ERGEBNISSE); } } 组件: import { Component
浏览 0
提问于2016-06-13
得票数 1
回答已采纳
1
回答
TypeError:无法读取属性的nonceStateSeparator
angular
、
oauth-2.0
、
azure-active-directory
目前,我正试图在我的angular应用程序中实现azure广告身份验证。不幸的是,我遇到了一个我不明白的错误。在我的应用程序中,我调用了角OAuth2-oidc包的tryLogin函数。在调用此函数之前,登录可以工作,因为它会给出以下错误: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'nonceStateSeparator' of null TypeError: Cannot read property 'nonceStateSeparator' of null
浏览 1
提问于2018-06-12
得票数 1
回答已采纳
2
回答
异步函数角服务
angular
、
promise
、
angular-httpclient
我的组件“ship”希望从后端服务器获取列表。所以,我做了一个服务(config.service.ts) import { Injectable, OnInit } from '@angular/core'; import { Observable, throwError } from 'rxjs'; import { catchError, retry } from 'rxjs/operators'; import { HttpClient } from '@angular/common/http'; @Injectabl
浏览 2
提问于2020-09-25
得票数 0
回答已采纳
2
回答
如何访问角订阅中的变量
angular
、
angular2-routing
、
angular7
我在访问已订阅的变量时遇到了问题。这里包括代码,在ngOninit中,我有返回对象的服务,从这个对象中,我可以得到我想要的json,然后我尝试将它存储在一个变量中,然后我尝试访问在订阅之外的变量,而这个变量是我做不到的。那么,我如何使用外部订阅变量。 ngOnInit() { const id = this.route.snapshot.paramMap.get('id'); this.dataService.GetFormById(+id).subscribe(response => { console.log(response);
浏览 1
提问于2019-04-10
得票数 1
回答已采纳
2
回答
为什么我不能在angular中保存get请求?
angular
、
get
、
httprequest
你好,我是从angular开始的,我不知道为什么这个没有任何帮助。 这很简单,我发出了一个get请求,我试图保存数据,但我做不到,我给你看了代码。 import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { HttpClient } from '@angular/common/http'; @Component({ selector: 'app-profile', templateUrl: './profile.component.
浏览 25
提问于2020-11-05
得票数 0
8
回答
角“`ngOnInit`”中的异步/等待
angular
、
typescript
、
asynchronous
、
promise
、
observable
我目前正在评估替换角的正负关系。RxJS‘Observable有普通的Promise,这样我就可以使用async和await,并获得更直观的代码风格。 我们典型的场景之一:在ngOnInit中加载一些数据。使用Observables,我们可以: ngOnInit () { this.service.getData().subscribe(data => { this.data = this.modifyMyData(data); }); } 当我从getData()返回一个getData()并使用async和await时,情况如下: async ngOnInit () {
浏览 0
提问于2019-05-11
得票数 99
回答已采纳
3
回答
Angular异步工厂提供程序
angular
、
angular-providers
我想建立一个工厂,它执行异步工作来返回服务,然后将该工厂提供给工厂提供者,以便在组件加载时为其提供服务。 但是,当提供程序将TestService注入到TestComponent中时,运行时的类型为ZoneAwarePromise。我需要一种方法,让提供者在将服务注入组件之前自动“等待”承诺。 服务 export class TestService { public test() { return 123; } } 提供程序和工厂 export function testFactory(auth: any, temp: any) { return new Promise((res
浏览 23
提问于2017-09-17
得票数 14
1
回答
ViewWrappedExcepetion错误为空,则不为空。
http
、
angular
我从angular2开始。我试图从php脚本中获取数据。 我在有角的医生跟前跟踪了塔楼。但我最近得到了一个令人困惑的错误描述: zone.js:463 ViewWrappedException {_wrapperMessage: "Error in app/components/catch-data/catch-data.component.html:7:5", _originalException: TypeError: Cannot read property 'name' of undefined at DebugAppView._View_Cat
浏览 3
提问于2016-05-24
得票数 0
回答已采纳
1
回答
错误TS2554:应为1个参数,但实际为0
angular
如何解决这个问题?有人能帮我吗? 使用Angular 5 我的angular方法: list.component.ts文件 ngOnInit() { this.getUserdata(1); } getUserdata(event){ this.userService.getUsers(event).then( users => { this.users = users; }, (error)=>{ return false;
浏览 3
提问于2018-03-10
得票数 1
2
回答
AngularJS $http.get异步执行顺序
javascript
、
json
、
angularjs
、
angularjs-http
、
hl7-fhir
我最近用AngularJS编写了很多代码。过了一段时间,它开始觉得舒服了,也变得很有效率。但不幸的是,有一件事我不明白: 在我的项目中,我需要通过$http.get和RESTful API服务器获取数据。这就是我开始跌跌撞撞的地方。在对处理数据的函数(如$q.defer等和.then)进行了实现之后,我认为我解决了这个问题。 但在这段代码中: $scope.getObservationsByLocations = function() { var promise = $q.defer(); var locationCount = 0; angu
浏览 3
提问于2015-07-09
得票数 6
回答已采纳
3
回答
无法获取api的数据
angular
、
api
、
model
、
angular-services
我有一个名为customer的组件,它用于使用api显示一些数据。 为了调用api,我创建了一个名为services.ts的文件,其代码如下所示: services.ts import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { I
浏览 1
提问于2018-12-05
得票数 0
回答已采纳
1
回答
在routerLink中使用来自angular2承诺的参数
angular
、
angular2-routing
、
angular2-template
我正在开发一个angular2应用程序。 我想使用一个参数,我得到了一个承诺。 我一直在犯这个错误: 异常: Uncaught (承诺中):错误:中由:C为空规范命令/__1@正常化命令@ createUrlTree@路由器 RouterLinkWithHref RouterLinkWithHref RouterLinkWithHref引起的错误 这是我的密码: some.component.ts: someAnswer: SomeAnswer; ngOnInit(): void { this.sub = this.route.params.subscribe(params =&
浏览 1
提问于2016-12-16
得票数 2
回答已采纳
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
Angular更改检测终极指南
NgRx 10引入组件本地状态管理包
AngularJs与服务器交互利用$http进行通信
ES6入门到“放弃
ES6 语法-Promise的用法
热门
标签
更多标签
活动推荐
运营活动
广告
关闭
领券