【发布时间】:2019-02-27 12:11:06
【问题描述】:
我正在关注this tutorial,尽我最大的努力不讨厌角。本教程使用 Typescript 和 Angular2 和 Ionic,这 3 个工具我并不完全理解,但这就像......为什么我首先要做一个教程。我在 Web 开发方面的经验是 Django 2.0 和很多前端,所以我非常了解 Javascript,但这让我感到困惑。
这是相关代码:
// chats.ts
import { Component } from '@angular/core';
import * as Moment from 'moment';
import { Observable } from 'rxjs/Observable';
import { Chat, MessageType } from '../../../../imports/models';
import template from './chats.html';
@Component({
template
});
export class ChatsPage {
chats: Observable<Chat[]>;
constructor() {
this.chats = this.findChats();
}
private findChats(): Observable<Chat[]> {
return Observable.of([
{
_id: '0',
title: 'Ethan Gonzalez',
picture: 'https://randomuser.me/api/portraits/thumb/men/1.jpg',
lastMessage: {
content: 'You on your way?',
createdAt: Moment().subtract(1, 'hours').toDate(),
type: MessageType.TEXT
}
},
// dummy data here
第二个文件:
// app.components.ts
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';
import { ChatsPage } from '../pages/chats/chats';
import template from "./app.html";
@Component({
template
});
export class MyApp {
rootPage = ChatsPage;
constructor(platform: Platform) {
platform.ready().then(() => {
if (platform.is('cordova')) {
StatusBar.styleDefault();
Splashscreen.hide();
}
});
}
}
运行 Meteor 时出现以下错误:
client/imports/pages/chats/chats.ts (13, 12): Cannot use namespace 'Observable' as a type.
client/imports/pages/chats/chats.ts (19, 26): Cannot use namespace 'Observable' as a type.
client/imports/app/app.components.ts (14, 27): Cannot use namespace 'Platform' as a type.
【问题讨论】:
-
您是否尝试再次运行
npm install?如果没有,请立即尝试。 -
@DiegoCardozo 它不起作用,但它确实留下了一堆关于
@angular/some-package requires a peer of rxjs@^6.0.0 but none is installed的消息。我尝试了npm install rxjs(应该已经可用),现在它是一堆不同的消息。我会尝试安装所有这些,看看是否有任何改变 -
@DiegoCardozo 不。依然没有。同样的错误
-
您可以使用您当前的设置发布一个存储库,以便我可以重现该问题吗?这比我自己尝试重新创建您的设置要容易得多。
-
@MattMcCutchen 在这里:github.com/yuvii/Trying-out-Angular
标签: angular typescript meteor ionic2