【发布时间】:2019-11-04 19:51:47
【问题描述】:
我正在尝试从 angular8 中的 HTTP 响应创建一个打字稿对象,但我收到一个错误:
错误参考错误:未定义配置文件 在 SafeSubscriber._next (app.service.ts:17) 在 SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:196) 在 SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (订阅者.js:134) 在 Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (订阅者.js:77) 在 Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (订阅者.js:54) 在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:41)
我的 Profile.ts 文件是:here 我的 app.service.ts 文件是:here
我用这个服务结果构造了一个组件类对象,我也得到了错误
错误类型错误:无法读取未定义的属性“名称”
当我在 HTML 文件中使用它时。
服务文件中语句的控制台输出为:
{
name: "somename",
status: "sometext",
bio: "sometext",
email: "email",
gitlab: "link",
twitter: "link",
instagram: "link",
linkedin: "link",
telegram: "link"
},
这是伴随错误的输出。
我的 HTML 代码很快就是:
<p class="ui header">{{profile.name}}</p>
我的组件类文件是:here
【问题讨论】:
-
对上述问题添加更新,现在,服务中的 console.log(this.profile) 语句打印数据。但是在组件中,没有打印数据。不知道为什么?
标签: javascript angular typescript angular8